Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to start persistent "tool" container with docker-compose? #11

Open
the-hotmann opened this issue May 20, 2022 · 2 comments
Open

How to start persistent "tool" container with docker-compose? #11

the-hotmann opened this issue May 20, 2022 · 2 comments

Comments

@the-hotmann
Copy link

I tried to set up a little tool-container with tools from cmd.cat to not having to install them on my host machine. But since I want to install and update them with docker-compose and keep the container running I set up my docker-compose file like this:

version: "3.8"
services:
  tools:
    image: cmd.cat/curl/wget
    container_name: tools
    volumes:
      - "/my_volume:/internal_volume"
    restart: unless-stopped

the command:
docker-compose pull tools && docker-compose up -d
runs through smooth, but then the container keeps on restarting and ends up in a restart loop:

docker exec -it tools /bin/bash
Error response from daemon: Container 4b4af273627611a793715af4c96d43xxxxxxxxxxxxxxxxxxxxxxxxx is restarting, wait until the container is running

Is there any good way, to run these cmd.cat tools in a persistent container so I don't have to start them with docker run -it everytime I want to use them?
Thanks in advance!

@the-hotmann the-hotmann changed the title How to start "tool" container with docker-compose? How to start persistent "tool" container with docker-compose? May 20, 2022
@the-hotmann
Copy link
Author

the-hotmann commented May 22, 2022

Found a workaround, so the container stays active and idles so you always have a ready container which you can access with:

docker exec -it tools /bin/bash

The workaround is, using the -d (detatched) parameter to start it, like this:

docker run --name tools -d -it cmd.cat/curl/wget

That gives the container the name tools and starts him in the background, so he does not terminate if you are not active in his terminal.

Sadly this is not a docker-compose way, but the old traditional docker way of starting things. Would be thankful for any hint how to do it with docker-compose, tried it already but nothing worked.

@lukaszlach
Copy link
Owner

The container has to be interactive, so -it has to be used when running docker run, same for docker-compose. The default command is always shell, so no need to change this one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants