一、Getting Started
docker run -dp 80:80 docker/getting-started
-d
- run the container in detached mode (in the background)-p 80:80
- map port 80 of the host to port 80 in the containerdocker/getting-started
- the image to use
You can combine single character flags to shorten the full command. As an example, the command above could be written as:
docker run -dp 80:80 docker /getting-started
二、Our Application
1. Download the ZIP
2. Building the App’s Container Image
- Create a field named
Dockerfile
FROM node:12-alpine
RUN apk add --no-cache python g++ make
WORKDIR /app
COPY . .
RUN yarn install --production
CMD ["node", "src/index.js"]
- docker build
docker build -t getting-restarted .
3. Starting an App Container
docker run -dp 3000:3000 getting-started
三、Updating our App
1. Updating our docker image
- update code
- update version of the image:
docker build -t getting-started
2. Removing a container using the CLI
- Get the ID of the container
docker ps
- Use