Questions tagged [docker-compose]

Compose is a tool for defining and running complex applications with Docker. With Compose, you define a multi-container application in a single file, then spin your application up in a single command which does everything that needs to be done to get it running.

Docker Compose is an officially supported tool to build multi-container applications. An application author or deployer creates a YAML file, generally named docker-compose.yml, that lists the containers or services that make up the application, along with other Docker-specific resources such as named volumes or containers. Docker Compose supports some features of , though it also works well for single-host Docker installations.

This tag is appropriate for questions about setting up the docker-compose.yml file and other questions about deployment or communication between containers managed by Docker Compose. It may be appropriate to tag your questions as as well. Please include a good extract of the docker-compose.yml file as a code block in your question, enough to reproduce the issue you are asking about.

Remember that questions must be programming-related. Questions on how to install Compose, how to use Compose to manage existing prebuilt images, or how to run someone else's Compose file are not programming-related and are not on topic for Stack Overflow.

Key links:

30464 questions
423
votes
10 answers

docker-compose up for only certain containers

I have a docker-compose.yml which contain several containers. Three of them are for my app (client, server and database) and the rest are for various dev tools (e.g. psql, npm, manage.py, etc). When I do docker-compose up all of them are started,…
aquavitae
  • 17,414
  • 11
  • 63
  • 106
415
votes
20 answers

How can I use environment variables in docker-compose?

I would like to be able to use environment variables inside docker-compose.yml, with values passed in at the time of docker-compose up. This is the example. I am doing this today with a basic docker run command, which is wrapped around my own…
Dmitry z
  • 4,533
  • 4
  • 15
  • 15
411
votes
12 answers

How do I define the name of image built with docker-compose

I'm using docker-compose to create my development environment. I want to build a specific image, but I don't know how to set a name for that image. wildfly: build: /path/to/dir/Dockerfile container_name: wildfly_server ports: - 9990:9990 …
Robert
  • 10,403
  • 14
  • 67
  • 117
400
votes
11 answers

How to get docker-compose to always re-create containers from fresh images?

My docker images are built on a Jenkins CI server and are pushed to our private Docker Registry. My goal is to provision environments with docker-compose which always start the originally built state of the images. I am currently using…
Kristof Jozsa
  • 6,612
  • 4
  • 28
  • 32
384
votes
5 answers

How to persist data in a dockerized postgres database using volumes

My docker compose file has three containers, web, nginx, and postgres. Postgres looks like this: postgres: container_name: postgres restart: always image: postgres:latest volumes: - ./database:/var/lib/postgresql ports: -…
Alex Lenail
  • 12,992
  • 10
  • 47
  • 79
375
votes
57 answers

An error, "failed to solve with frontend dockerfile.v0"

I was trying to build my Docker image for my Gatsby application. Whenever I run the command docker build . -t gatsbyapp, it gives me an error: failed to solve with frontend dockerfile.v0: failed to build LLB: failed to compute cache key: "/.env" not…
Muhammad Yasir
  • 3,814
  • 2
  • 5
  • 8
369
votes
8 answers

How do I mount a host directory as a volume in docker compose

I have a development environment I'm dockerizing and I would like the ability to livereload my changes without having to rebuild docker images. I'm using docker compose because redis is one of my app's dependencies and I like being able to link a…
Amin Shah Gilani
  • 8,675
  • 5
  • 37
  • 79
369
votes
4 answers

What is the difference between docker and docker-compose

docker and docker-compose seem to be interacting with the same dockerFile, what is the difference between the two tools?
Hafiz
  • 4,921
  • 3
  • 19
  • 28
338
votes
23 answers

Is it safe to clean docker/overlay2/

I got some docker containers running on AWS EC2, the /var/lib/docker/overlay2 folder grows very fast in disk size. I'm wondering if it is safe to delete its content? or if docker has some kind of command to free up some disk usage. UPDATE: I…
qichao_he
  • 4,204
  • 4
  • 15
  • 24
335
votes
7 answers

Difference between "docker compose" and "docker-compose"

Note: this question was created BEFORE docker docs were updated (it was the reason they were updated - see this answer). Please do not post answers pointing out the docs on the differences :-) I have been using docker-compose, but noticed there is…
Veverke
  • 9,208
  • 4
  • 51
  • 95
331
votes
28 answers

Docker "ERROR: could not find an available, non-overlapping IPv4 address pool among the defaults to assign to the network"

I have a directory apkmirror-scraper-compose with the following structure: . ├── docker-compose.yml ├── privoxy │   ├── config │   └── Dockerfile ├── scraper │   ├── Dockerfile │   ├── newnym.py │   └── requirements.txt └── tor └──…
Kurt Peek
  • 52,165
  • 91
  • 301
  • 526
289
votes
35 answers

Docker Error bind: address already in use

When I run docker-compose up in my Docker project it fails with the following message: Error starting userland proxy: listen tcp 0.0.0.0:3000: bind: address already in use netstat -pna | grep 3000 shows this: tcp 0 0 0.0.0.0:3000 …
Ngoral
  • 4,215
  • 2
  • 20
  • 37
282
votes
19 answers

Docker-compose: node_modules not present in a volume after npm install succeeds

I have an app with the following services: web/ - holds and runs a python 3 flask web server on port 5000. Uses sqlite3. worker/ - has an index.js file which is a worker for a queue. the web server interacts with this queue using a json API over…
KGo
  • 18,536
  • 11
  • 31
  • 47
278
votes
7 answers

How to pass arguments to entrypoint in docker-compose.yml

I use this image: dperson/samba The image is defining its own entrypoint and I do not want to override it. I need to pass arguments to the entrypoint, easy with docker only: docker run ... dperson/samba arg1 arg2 arg3 But how to do it with…
user1707414
  • 3,833
  • 2
  • 18
  • 19
276
votes
23 answers

Why is Docker installed but not Docker Compose?

I have installed docker on CentOS 7 by running following commands, curl -sSL https://get.docker.com/ | sh systemctl enable docker && systemctl start docker docker run hello-world NOTE: helloworld runs correctly and no issues. however when I try to…
mahen3d
  • 7,047
  • 13
  • 51
  • 103