Q. How to run docker-compose in detach mode
I am trying to run docker-compose in detach mode but it will exits after just it's run, but I am able run same image in detach mode using 'docker run' command.
Run image using 'docker run' command (works in detach mode)
docker run -itd ubuntu:16.04
below is output of 'docker ps -a' command
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
d84edc987359 ubuntu:16.04 "/bin/bash" 4 seconds ago Up 3 seconds romantic_albattani
Run same image using 'docker-compose up -d' command (didn't work in detach mode)
below is my docker-compose.yml file
version: '3'
services:
ubuntu:
image: ubuntu:16.04
'docker-compose ps' command output
Name Command State Ports
----------------------------------------------------
composetesting_ubuntu_1 /bin/bash Exit 0
Update: When using tty: true parameter in docker-compose.yml file as below
version: '3'
services:
ubuntu:
image: ubuntu:16.04
tty: true
then console will not execute any command, like if I type 'ls -l' command console will not responding.
I just had to add tty: true to my docker-compose.yml
version: '2'
services:
ubuntu:
image: ubuntu:16.04
tty: true
Docker version 1.12.5, build 7392c3b
docker-compose version 1.7.1, build 0a9ab35
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With