Docker的简单安装与使用

参考
https://www.docker.com/ 官网
https://www.missshi.cn/api/view/blog/5a6327d10a745f6335000005 自定义镜像(nginx)
https://www.cnblogs.com/Dicky-Zhang/p/6925202.html 常用命令
https://blog.csdn.net/qazplm12_3/article/details/73436708 安装运行镜像上传
https://www.cnblogs.com/lyq863987322/p/8516958.html k8s

一. 安装docker

#更新yum源
yum update -y

# 安装Docker
yum install docker

# 启动Docker服务
systemctl start docker

# 安装依赖服务
yum install perl
yum install make
yum install kernel-devel-$(uname -r)

# 设置Docker开机启动
systemctl status docker
systemctl enable docker

二 .拉取测试镜像hello-world

  1. 查找镜像 docker search hello-word

  2. 拉取镜像 docker pull hello-word

  3. 查看镜像 docker images

  4. 运行镜像 docker run -d hello-word

  5. 查看容器 docker ps (查看运行中的容器) docker ps -a(查看所有容器)

  6. 关闭容器 docker stop 容器名

  7. 删除容器 docker rm 容器名

三. 在容器中安装nginx

  1. 查找镜像 docker search nginx

  2. 拉取镜像 docker pull nginx

  3. 查看镜像 docker images

  4. 运行镜像 docker run -d -p 80:80 镜像名(-d 后台运行 -p 80:80 将本机80端口映射到容器80端口)
    docker run -d -it -p 80:80 镜像名(-it 交互式运行,运行后切换到容器内部)

5.docker exec -it 容器名 /bin/sh 进入容器(ctrl+D 退出)
自带安装软件 apt-get

6.在浏览器输入本机ip进入nginx页面

导出容器 docker export b91d9ad83efa > tomcat80824.tar
导入容器 docker import tomcat80824.tar
容器更新为镜像 docker commit -m=“eth镜像” 79236b07f50f eth-node
导出镜像 docker save IMAGEID > eth-new2.tar
导入镜像 docker load <eth-new2.tar
备注镜像 docker tag IMAGEID eth-new:1.0
镜像导入和容器导入的区别:
1)容器导入 是将当前容器 变成一个新的镜像
2)镜像导入 是复制的过程
save 和 export区别:
1)save 保存镜像所有的信息-包含历史
2)export 只导出当前的信息

猜你喜欢

转载自blog.csdn.net/qq_35331140/article/details/86512288