Cloudron makes it easy to run web apps like WordPress, Nextcloud, GitLab on your server. Find out more or install now.


    Cloudron Forum

    • Register
    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular

    Solved running command inside container

    Support
    exec
    4
    7
    70
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • P
      perler last edited by girish

      for an import script I want to run a bash command inside a (here: nextcloud..) container. This instruction to identify the container from the hostname doesn't seem to work anymore:

      https://forum.cloudron.io/post/2011

      what's the current approach?

      fbartels 1 Reply Last reply Reply Quote 0
      • nebulon
        nebulon Staff last edited by

        The script mentioned in the other forum post should still work fine. At its core is the following docker cli line to detect the container id:

        docker ps -q -f label=fqdn=$app -f label=isSubcontainer=false
        

        The attributes it filters on have not changed since then.

        1 Reply Last reply Reply Quote 2
        • fbartels
          fbartels App Dev @perler last edited by

          Hi @perler

          from the settings of the app on in the Cloudron dashboard you could open a terminal. which will give you access to the container.

          You could also use the cloudron cli from your workstation. cloudron exec --app $locationofyournextcloud.

          1 Reply Last reply Reply Quote 0
          • P
            perler last edited by

            we want to use this in a script which runs locally on the cloudron server - what would be the preferred way here?

            fbartels 1 Reply Last reply Reply Quote 0
            • fbartels
              fbartels App Dev @perler last edited by

              @perler is this a one off thing, or something to run on a regular base?

              Personally I would use cloudron exec, but if you're planning to run the task regularly then it may be better to add this to the cron jobs of the app.

              1 Reply Last reply Reply Quote 1
              • P
                perler last edited by

                it's a one off thing, but preferrable within a script (so it should resolve the local container-id by hostname)

                girish 1 Reply Last reply Reply Quote 0
                • nebulon
                  nebulon Staff last edited by

                  The script mentioned in the other forum post should still work fine. At its core is the following docker cli line to detect the container id:

                  docker ps -q -f label=fqdn=$app -f label=isSubcontainer=false
                  

                  The attributes it filters on have not changed since then.

                  1 Reply Last reply Reply Quote 2
                  • Topic has been marked as a question  nebulon nebulon 
                  • girish
                    girish Staff @perler last edited by

                    @perler Have you seen https://docs.cloudron.io/apps/#cron already? This will run the job in the context of a container.

                    I am happy to add other "meta" patterns, if none of those fit your use case 🙂

                    1 Reply Last reply Reply Quote 0
                    • Topic has been marked as solved  girish girish 
                    • First post
                      Last post
                    Powered by NodeBB