Ketone16 / docker-compose

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

docker-compose

Tutorial: Get started with Docker Compose

How can I start my services in the background?

docker compose up -d

How can I see what environment variables are available to the $SERVICE service defined in my docker-compose file?

SERVICE=web
docker compose run $SERVICE env

Note how this creates a container and then exists

$ docker ps -a
CONTAINER ID   IMAGE                COMMAND                  CREATED          STATUS                     PORTS     NAMES
0352eb7204cf   docker-compose_web   "env"                    2 seconds ago    Exited (0) 1 second ago              docker-compose_web_run_cf43592bca36
567aa67651ab   docker-compose_web   "env"                    3 minutes ago    Exited (0) 3 minutes ago             docker-compose_web_run_a506a07db24

How can I stop services running in the background?

docker compose stop

How can I bring everything down, removing the containers entirely? What if I also want to remove the data volume?

docker compose down

And to also remove the data volume:

docker compose down --volumes

Will stopping (ctrl+C or docker compose stop) remove containers?

No, the containers just exit. docker compose down will remove the containers. The stopped container is why the counter will remain the same when runing docker compose up in a loop while stopping it each time, the data remains the redis container.

About


Languages

Language:Dockerfile 55.7%Language:Python 44.3%