Docker 基础

Docker 基础

下载 Docker

1
2
# ubuntu
sudo apt install docker

寻找镜像

1
sudo docker search centos

拉取镜像

1
2
# 按照 docker pull image-name:tag 的形式
sudo docker pull centos:latest

查看 docker 镜像

1
sudo docker images

image-20220520220514030

对于 docker 无法下载,出现

1
Error: Failed to download metadata for repo 'AppStream': Cannot prepare internal mirrorlist: No URLs in mirrorlist

可以进行添加源

1
2
3
4
5
6
7
cd /etc/yum.repos.d/
sed -i 's/mirrorlist/#mirrorlist/g' /etc/yum.repos.d/CentOS-*

sed -i 's|#baseurl=http://mirror.centos.org|baseurl=http://vault.centos.org|g' /etc/yum.repos.d/CentOS-*

# 接着更新
yum update -y

打包容器

先不要急着退出 (exit),执行下列命令打包

1
2
3
4
sudo docker commit -m "what you want to say...." -a author_of_this_container aca395e4afa3 [REPOSITORY[:TAG]]

# for example
sudo docker commit -m "docker with appstream , git and a user called wayen" -a mydocker aca395e4afa3 mydocker/centos:first

使用以下命令查看

1
sudo docker images

image-20220520224635922


Docker 基础
http://home.ustc.edu.cn/~ustcxwy0271/2022/05/22/docker-1/
作者
Xu Weiye
发布于
2022年5月22日
许可协议