2

I'm new to docker and I'm using a compose file to build from a Dockerfile and run and image for me I have the following yml file

version: '2'

services:
  multichain:
    build: ./
    image: ubuntu:15.04
    read_only: false
    volumes:
      - .:/data:rw
    working_dir: /data
    #entrypoint: node server/index.js

docker-compose up --build produces

REPOSITORY          TAG                 IMAGE ID            CREATED             SIZE
<none>              <none>              5c5580fb6ce4        2 minutes ago       175.1 MB
ubuntu              15.04               d1b55fd07600        10 months ago       131.3 MB

Which is expected but can I replace the "" with something during the build in docker-compose?

Also when I run the file again it will create another : can't I just replace whats already there?

1
  • Passing ./ to your build which you're also using inside the rw volume just about guarantees the build context will never be cached. You can improve caching by using .dockerignore and moving your volume. – BMitch Dec 4 '16 at 20:39
2

Docker doesn't replace images, you have to run another command to delete the old ones. According to https://docs.docker.com/compose/compose-file/#/build, by adding 'image' after 'build' you are instructing docker to label your new build as ubuntu:15.04.

You don't want to specify the base image in the compose file, the Dockerfile FROM does that.

I think you want to change ubuntu:15.04 in your example to something like myapp:latest

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.