I am trying to create two dockers: one nginx and the other nodejs. However, I find two sets of images are being created. I have deleted all existing images and rebooted the system, yet it shows as below. The relevant files are below.
The following is the docker-compose.yml
services:
nginx:
build: ./nginx
restart: always
ports:
- "80:80"
links:
- node:node
node:
build: ./node
restart: always
ports:
- "8080:8080"
volumes:
- ./node:/usr/src/app
- /usr/src/app/node_modules
The nginx Dockerfile is as follows:
FROM nginx
COPY nginx.conf /etc/nginx/conf.d/default.conf
And the NodeJS Dockerfile as follows:
FROM node:9.3.0-alpine
WORKDIR /usr/src/app
COPY package.json /usr/src/app/
RUN npm install
COPY . /usr/src/app
EXPOSE 8080
CMD [ "npm", "start" ]
The docker images
command shows:
REPOSITORY TAG IMAGE ID CREATED SIZE
hudddle_nginx latest f784ac4611f5 5 minutes ago 108MB
hudddle_node latest 5e083ec259e7 5 minutes ago 70.4MB
node 9.3.0-alpine 466bcf8bf36e 3 days ago 67.6MB
nginx latest f895b3fb9e30 5 days ago 108MB
Why is it so? The Server (AWS) was created today. Thanks
Thats the correct behaviour
As you using FROM nginx and FROM node in dockerfile, while building docker gets nginz and node images from dockerhub.
So when you want to build docker again , this time it will not download from dockerhub instead it uses local cached image.
Maybe you using below commands to build
docker build -t hudddle_nginx .
docker build -t hudddle_node .
Because of that its base images first nginx and node and then your custom images hudddle_nginx,hudddle_node
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.