Docker
本文最后更新于 409 天前,其中的信息可能已经有所发展或是发生改变。

安装

官网

https://docs.docker.com/engine/install/ubuntu/#set-up-the-repository

清华源

https://mirrors.tuna.tsinghua.edu.cn/help/docker-ce/

Install

sudo apt-get install apt-transport-https ca-certificates curl gnupg2 software-properties-common -y

sudo mkdir -p /etc/apt/keyrings

sudo apt-get update

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg

echo \
  "deb [arch=$(dpkg --print-architecture) signed-by=/etc/apt/keyrings/docker.gpg] https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu \
  $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin -y

sudo docker run hello-world

测试

docker run hello-world
test

换源

在 /etc/docker/daemon.json 中写入:

{"registry-mirrors":["https://docker.mirrors.ustc.edu.cn/"]}

科大镜像:https://docker.mirrors.ustc.edu.cn/
网易:https://hub-mirror.c.163.com/
阿里云:https://<你的ID>.mirror.aliyuncs.com
七牛云加速器:https://reg-mirror.qiniu.com
清华源:https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/ubuntu

重启服务

$ sudo systemctl daemon-reload
$ sudo systemctl restart docker

如果换源生效,运行 docker info,将出现类似结果

Registry Mirrors:
  https://docker.mirrors.ustc.edu.cn/ 

查看阿里云地址 阿里云

USAGE

拉取镜像

docker pull <mirror name>

通过 Dockerfile 创建容器

docker build -t <name> .

通过 docker-compose 创建容器

docker-compose up -d

查看当前容器

docker ps
docker ps -a

查看所有镜像

docker images

删除容器

docker rmi <id>

删除镜像

docker rm <id>

启动容器

docker run -it <image> /bin/bash

复制粘贴

docker cp <id>:<path> <path>

Dockerfile

Example

FROM ubuntu:20.04

copy /home/jbnrz/Desktop/files /files

RUN apt-get update && apt-get install python3

CMD ["python3", "-m", "http.server"]
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇