Docker安装(CentOS)
一键卸载旧的
sudo yum remove docker*
一行代码(自动安装)
使用官方安装脚本
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
备注1:如果报错的话 curl: (6) Could not resolve host: get.docker.com; Unknown error
安装docker环境报错:Could not resolve host_curl: (6) could not resolve host: get.docker.com-优快云博客
启动 docker并查看状态
systemctl start docker
systemctl status docker
运行镜像 hello-world
docker run hello-world
简单使用
使用 docker run 命令
在容器内运行一个应用程序比如: docker run hello-world
安装node
docker pull node:latest
docker images
运行node容器
docker run -itd --name node-test node
进入容器
docker exec -it node-test /bin/bash
### 安装 https://blog.youkuaiyun.com/lxlsygxs2017/article/details/129973983 第一步:卸载 查看 yum list installed | grep docker 卸载 yum remove docker-* 第二步:更新Linux的内核, yum update 第三步:安装 docker 容器 安装工具包 yum install -y yum-utils device-mapper-persistent-data lvm2 设置远程仓库 yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo 安装 yum install docker-ce 第四步:启动docker容器 启动 systemctl start docker 有问题的话查看 tail -200f /var/log/messages 第五步:检查docker容器状态 systemctl status docker ### run demo docker run hello-world ### 查找镜像 1.可以从 Docker Hub 网站来搜索镜像,Docker Hub 网址为: https://hub.docker.com/ 2.我们也可以使用 docker search 命令来搜索镜像。比如我们需要一个 httpd 的镜像来作为我们的 web 服务。 docker search httpd 3.拖取镜像 docker pull httpd 4.使用镜像 docker run httpd 5.删除镜像 docker rmi hello-world 删除镜像时报错: 删除/var/lib/docker/image/overlay2/imagedb/content/sha256目录下相应的镜像文件即可 ### Docker 容器使用命令 https://blog.youkuaiyun.com/weixin_38235865/article/details/114867285 1.交互模式:-t: 在新容器内指定一个伪终端或终端 -i: 允许你对容器内的标准输入 (STDIN) 进行交互。 docker run -it image_id /bin/bash docker run -it a6ca7b52a415 /bin/bash ctrl+d 退出 2.后台模式:-d 参数时,容器启动后会进入后台。 docker run -d image_id /bin/sh -c "while true; do echo hello world; sleep 1; done" docker run -d a6ca7b52a415 /bin/bash 进入终端模式 docker ps 查找到 CONTAINER ID docker exec -it 21878ebdc655 /bin/bash 停止/重启/删除容器 docker stop 21878ebdc655 docker restart 21878ebdc655 docker rm -f 21878ebdc655