skip to Main Content

Is it possible just to start a single container among a group of stopped Docker Compose container?

I have a docker-compose.yml file that contains 4 containers: redis, postgres, api and worker. If all of them has stopped, can I start just one of them to check the config files within it? I’m getting

you cannot start and attach multiple containers at once

and I’m wondering if there is any way to work around it.

2

Answers


  1. It’s hard to exactly answer your question without an mvp compose file that gets the error you want. But you don’t need to start the container to look at a config file in it.

    Look at the docker mount, unmount, cp, and export commands.

    Login or Signup to reply.
  2. You can run a single container with command

    docker compose start <service-name>
    

    Note: it won’t work if your service/container are depends on another
    service/container.

    If you want to check the config files within it, you could just run

    docker compose run -it <service-name> sh
    

    Note: it will create and running a new container.

    Another way to do it is by copying the config file directly without running the stopped container with this command

    docker compose cp <service-name>:<config-file-path> <destination>
    
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search