docker的安装与命令
1.docker pull xxxx 拉取镜像
2.docker images 查看已经下载的镜像
3.docker search 去官网搜索镜像
4.docker 实现环境的一比一复制
5.docker ps 查看状态是启动着的容器
6.docker ps -a 查看所有启动过的容器
7.docker rm ID/name 移除容器 (先停止后移除)
8.docker run -d -p 4416:3306(外部暴露接口:内部实际接口)xxxxx(name):Vx(版本)(运行数据库的命令)
root@cc-virtual-machine:/etc/docker# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ffff8eb4d7dd registry.cn-hangzhou.aliyuncs.com/zhufc/mysql:v2 "/usr/local/mysql/bi 7 minutes ago Up 7 minutes 22/tcp, 0.0.0.0:4416->3306/tcp nostalgic_perlman
root@cc-virtual-machine:/etc/docker# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ffff8eb4d7dd registry.cn-hangzhou.aliyuncs.com/zhufc/mysql:v2 "/usr/local/mysql/bi 7 minutes ago Up 7 minutes 22/tcp, 0.0.0.0:4416->3306/tcp nostalgic_perlman
root@cc-virtual-machine:/etc/docker#
docker安装步骤:
1.安装docker : apt-get install docker.io
root@cc-virtual-machine:~/wuge/java/apache-tomcat-8.5.29/bin# apt-get install docker.io
正在读取软件包列表... 完成
2.安装加速器
mkdir -p /etc/docker (创建docker文件夹,-p的意思是级联,同时创建两个文件夹的意思)
root@cc-virtual-machine:~/wuge/java/apache-tomcat-8.5.29/bin# cd /etc/docker/
3.拉取数据库
docker pull xxxxxxxxx:v2 root 000000
root@cc-virtual-machine:/etc/docker# docker pull registry.cn-hangzhou.aliyuncs.com/zhufc/mysql:v2
v2: Pulling from registry.cn-hangzhou.aliyuncs.com/zhufc/mysql
4.查看镜像,看是否pull成功
docker images
root@cc-virtual-machine:/etc/docker# docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
registry.cn-hangzhou.aliyuncs.com/zhufc/mysql v2 82eeec81411c 3.275873 years ago 4.617 GB
5.启动容器
docker run -d -p 4416:3306(外部暴露接口:内部实际接口)xxxxx(name):Vx(版本)(运行数据库的命令)
root@cc-virtual-machine:/etc/docker# docker run -d -p 4416:3306 registry.cn-hangzhou.aliyuncs.com/zhufc/mysql:v2
0d13732b0edd8ff354f305b6346fbe0457b373083d63e2d1bc0d0ab3b8ba0bd9
整个步骤:
root@cc-virtual-machine:~/wuge/java/apache-tomcat-8.5.29/bin# cd /etc/docker/
root@cc-virtual-machine:/etc/docker# ll
总用量 20
drwx------ 2 root root 4096 1月 17 22:47 ./
drwxr-xr-x 124 root root 12288 1月 17 22:47 ../
-rw------- 1 root root 281 1月 17 22:47 key.json
root@cc-virtual-machine:/etc/docker# tee /etc/docker/123.json <<-'EOF' (加速器)
> {
> "registry-mirrors": ["https://1vtrf9ho.mirror.aliyuncs.com"]
> }
> EOF
{
"registry-mirrors": ["https://1vtrf9ho.mirror.aliyuncs.com"]
}
root@cc-virtual-machine:/etc/docker# ll
总用量 24
drwx------ 2 root root 4096 1月 17 22:50 ./
drwxr-xr-x 124 root root 12288 1月 17 22:47 ../
-rw-r--r-- 1 root root 67 1月 17 22:50 123.json
-rw------- 1 root root 281 1月 17 22:47 key.json
root@cc-virtual-machine:/etc/docker# cat 123.json
{
"registry-mirrors": ["https://1vtrf9ho.mirror.aliyuncs.com"]
}
root@cc-virtual-machine:/etc/docker# docker pull registry.cn-hangzhou.aliyuncs.com/zhufc/mysql:v2