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


Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Bookmarks
  • Search
Skins
  • Light
  • Brite
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Brand Logo

Cloudron Forum

Apps - Status | Demo | Docs | Install
  1. Cloudron Forum
  2. Support
  3. running command inside container

running command inside container

Scheduled Pinned Locked Moved Solved Support
exec
7 Posts 4 Posters 2.2k Views 4 Watching
  • 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 Offline
    P Offline
    perler
    wrote on last edited by girish
    #1

    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?

    fbartelsF 1 Reply Last reply
    0
    • nebulonN Offline
      nebulonN Offline
      nebulon
      Staff
      wrote on last edited by
      #6

      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
      2
      • P perler

        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?

        fbartelsF Offline
        fbartelsF Offline
        fbartels
        App Dev
        wrote on last edited by
        #2

        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
        0
        • P Offline
          P Offline
          perler
          wrote on last edited by
          #3

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

          fbartelsF 1 Reply Last reply
          0
          • P perler

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

            fbartelsF Offline
            fbartelsF Offline
            fbartels
            App Dev
            wrote on last edited by
            #4

            @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
            1
            • P Offline
              P Offline
              perler
              wrote on last edited by
              #5

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

              girishG 1 Reply Last reply
              0
              • nebulonN Offline
                nebulonN Offline
                nebulon
                Staff
                wrote on last edited by
                #6

                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
                2
                • nebulonN nebulon marked this topic as a question on
                • P perler

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

                  girishG Offline
                  girishG Offline
                  girish
                  Staff
                  wrote on last edited by
                  #7

                  @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
                  0
                  • girishG girish has marked this topic as solved on

                  Hello! It looks like you're interested in this conversation, but you don't have an account yet.

                  Getting fed up of having to scroll through the same posts each visit? When you register for an account, you'll always come back to exactly where you were before, and choose to be notified of new replies (either via email, or push notification). You'll also be able to save bookmarks and upvote posts to show your appreciation to other community members.

                  With your input, this post could be even better 💗

                  Register Login
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • Bookmarks
                  • Search