docker官方教程笔记

这篇博客详细记录了Docker的使用过程,包括启动容器、构建应用镜像、更新应用、分享应用到Docker Hub、持久化数据库、使用绑定挂载以及管理多容器应用。还介绍了如何使用Docker Compose来管理复杂的应用栈。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

一、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 container
  • docker/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
    
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值