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
271
votes
1 answer

How to pass arguments to a Dockerfile?

I am using RUN instruction within a Dockerfile to install a rpm RUN yum -y install samplerpm-2.3 However, I want to pass the value "2.3" as an argument. My RUN instruction should look something like: RUN yum -y install samplerpm-$arg where…
meallhour
  • 13,921
  • 21
  • 60
  • 117
263
votes
9 answers

How to run docker-compose up -d at system start up?

To let the containers autostart at startup point, I tried to add the command: cd directory_has_docker-compose.yml && docker-compose up -d in /etc/rc.local. but then after I reboot the machine, the containers not work. How run docker-compose…
user39544
  • 3,227
  • 2
  • 14
  • 8
260
votes
1 answer

docker-compose up vs docker-compose up --build vs docker-compose build --no-cache

I couldn't figure out what the difference between those. docker-compose up docker-compose up --build docker-compose build --no-cache Is there any command for upwithout cache?
Toshi
  • 6,012
  • 8
  • 35
  • 58
257
votes
24 answers

How to upgrade docker-compose to latest version

I have installed docker-compose using the command sudo apt install docker-compose It installed docker-compose version 1.8.0 and build unknown I need the latest version of docker-compose or at least a version of 1.9.0 Can anyone please let me know…
Sam_2207
  • 2,759
  • 2
  • 9
  • 15
255
votes
34 answers

Can't connect to docker from docker-compose

I installed docker-machine 0.1.0 and docker-compose 1.1.0 on Mac OS 10.8.5.Docker-machine is running normally and able to connect by docker-machine ssh. $ docker-machine ls NAME ACTIVE DRIVER STATE URL SWARM dev…
DIGITALSQUAD
  • 3,384
  • 3
  • 22
  • 24
253
votes
6 answers

How to specify Memory & CPU limit in docker compose version 3

I am unable to specify CPU and memory limitation for services specified in version 3. With version 2 it works fine with mem_limit & cpu_shares parameters under the services. But it fails while using version 3, putting them under deploy section…
vivekyad4v
  • 13,321
  • 4
  • 55
  • 63
250
votes
12 answers

How do I make a Docker container start automatically on system boot?

Supposed I have a Docker container that I want to run, then I can call $ docker run ... and everything is fine. Is there a built-in way to run a container in a way that it will be restarted automatically, if the system crashes and reboots? If so,…
Golo Roden
  • 140,679
  • 96
  • 298
  • 425
244
votes
11 answers

What is the best way to pass AWS credentials to a Docker container?

I am running docker-container on Amazon EC2. Currently I have added AWS Credentials to Dockerfile. Could you please let me know the best way to do this?
suraj chopade
  • 2,833
  • 3
  • 13
  • 15
243
votes
8 answers

Docker-Compose persistent data MySQL

I can't seem to get MySQL data to persist if I run $ docker-compose down with the following .yml version: '2' services: # other services data: container_name: flask_data image: mysql:latest volumes: - /var/lib/mysql …
Adam
  • 3,992
  • 2
  • 19
  • 39
237
votes
4 answers

What is the purpose of the file "docker.sock"?

I am trying to understand the actual reason for mounting docker.sock in docker-compose.yml file. Is it for auto-discovery? volumes: - /var/run/docker.sock:/var/run/docker.sock
uzubair
  • 2,391
  • 2
  • 12
  • 3
237
votes
6 answers

How do I set hostname in docker-compose?

In my docker-compose.yml file, I have the following. However the container does not pick up the hostname value. Any ideas? dns: image: phensley/docker-dns hostname: affy domainname: affy.com volumes: -…
David Medinets
  • 5,160
  • 3
  • 29
  • 42
230
votes
7 answers

How to update existing images with docker-compose?

I have multiple microservices and I am using docker-compose for development deployments. When there are some changes in the microservices code base, I am triggering ci job to re-deploy them. I have below script to do this. But each time I have to…
Efe
  • 5,180
  • 2
  • 21
  • 33
229
votes
5 answers

E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is required for this operation

I have installed docker on windows 10 pro. I am facing an issue while running the following command in git-bash. docker-compose up -d --build and got following error. E: gnupg, gnupg2 and gnupg1 do not seem to be installed, but one of them is…
Saif
  • 2,873
  • 2
  • 12
  • 30
225
votes
9 answers

How to tag docker image with docker-compose

I want to build image via docker-compose and set specific tag to it. Documentation says: Compose will build and tag it with a generated name, and use that image thereafter. But I can't find a way to specify tag and for built images I always see…
4ybaka
  • 2,954
  • 4
  • 16
  • 21
221
votes
15 answers

Docker Compose keep container running

I want to start a service with docker-compose and keep the container running so I can get its IP-address via 'docker inspect'. However, the container always exits right after starting up. I tried to add "command: ["sleep", "60"]" and other things to…
dingoglotz
  • 2,553
  • 3
  • 17
  • 21