We were trying to build and run docker-compose project on remote host. I tried using:
docker-compose -H 'ssh://remote_address' up --build
And got
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
So we tried:
docker-compose -H 'ssh://remote_address' build
docker-compose -H 'ssh://remote_address' up
Which worked fine. My problem is I can't find evidence in docs for this to be correct behaviour. Is this a bug in docker-compose, a feature, or a bug in my environment?
I'm not sure of the error you got for the first command, I mean docker-compose -H 'ssh://ip' up --build
as it may be really a but, but the three mentioned commands have surely differences. I'll try to explain in my simple way:
docker-compose up --build
.This command finds docker-compose
file and rebuilds the image then make it running. Suppose you have made some changes into your docker-compose
file, so when you only run docker-compose
, you'll get a warning that image is not rebuilt, you should run docker-compose up --build
to rebuild it and make everything be built again (despite something done before and present in cache).
docker-compose build
.This command only builds your image based on docker-compose
, but does not run it. You can see the built image by docker image ls
or docker images
. Also executing docker ps -a
should not see your recent built image running.
docker-compose up
.If this command is entered for the first time, it tries to run everything in Dockerfile
if exists and download base image, etc. Then makes the image and runs the container.
If the image has been built before, it just runs it.
Unlike the first command, the third one only runs the latest build of that image, but would not build it again.
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