Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

"Docker-compose up" does not pull images everytime , it recreates a pulled image

I have a Dockerfile with the following contents:

FROM <docker-registry>/<image>:latest
COPY mv setup /root/
RUN setup

When I do a docker-compose up -d, Docker pulls the image and executes the steps.

When I do a docker-compose stop and bring it back up, docker-compose dos not pull the latest image again. This is a problem for me as I will need a new image to be downloaded. The only way for me to do this is to blow up boot2docker vm and start over again.

like image 913
user1807948 Avatar asked Mar 07 '15 19:03

user1807948


2 Answers

You should use docker-compose pull command to pull remote image, use docker-compose build command to build local image, then use docker-compose up -d to recreate your container.

$ cd /path/to/folder

$ cat docker-compose.yml
myapp:
  build: .
  links:
    - redis    
redis:
  image: redis

# pull lastest image
$ docker-compose pull redis

# build your image
$ docker-compose build myapp

# recreate containers
$ docker-compose up -d
like image 170
kev Avatar answered Sep 24 '22 03:09

kev


Docker Compose version 1.5.0rc1 can now pull latest images referenced in Dockerfiles on build by using docker-compose build --pull.

Before 1.5.0rc1 docker-compose could not force a Dockerfile service to get the latest image. I had to use docker pull <image>.

Once the new imaged has been pulled, then you can rebuild with docker-compose build. Cache should be totally invalidated because step 0's FROM hash has changed, if the image has changed.

like image 41
Dave Avatar answered Sep 27 '22 03:09

Dave