虚拟机安装docker教程
时间: 2023-11-17 09:05:26 浏览: 101
以下是在虚拟机中安装Docker的步骤:
1.卸载旧版本的Docker(如果有):
```bash
yum remove docker docker-common docker-selinux docker-engine
```
2.安装必要的依赖包:
```bash
sudo yum install -y yum-utils device-mapper-persistent-data lvm2
```
3.添加Docker的yum源:
```bash
sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
```
4.安装Docker CE:
```bash
sudo yum install docker-ce docker-ce-cli containerd.io
```
5.启动Docker并设置开机自启:
```bash
sudo systemctl start docker
sudo systemctl enable docker
```
6.验证Docker是否安装成功:
```bash
sudo docker run hello-world
```
相关问题
虚拟机 ubuntu安装docker教程
在Ubuntu系统上安装Docker,你可以按照以下步骤操作:
1. **更新包列表**:
```
sudo apt-get update
```
2. **安装依赖**:
```
sudo apt-get install apt-transport-https ca-certificates curl gnupg lsb-release
```
3. **添加Docker GPG密钥**:
```
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg
```
4. **修改apt源**:
```
echo "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
```
5. **再次更新并安装Docker**:
```
sudo apt-get update
sudo apt-get install docker-ce docker-ce-cli containerd.io
```
6. **启动并启用Docker服务**:
```
sudo systemctl start docker
sudo systemctl enable docker
```
7. **验证Docker是否安装成功**:
```
sudo docker run hello-world
```
如果你想要查看更详细的安装过程或遇到问题,可以查阅官方文档:https://docs.docker.com/engine/install/ubuntu/
虚拟机离线安装docker
要在虚拟机上离线安装Docker,可以按照以下步骤进行操作。
1. 首先,你需要在一台能联网的机器上下载Docker的安装包。可以使用`yum`命令,并指定`--downloadonly`和`--downloaddir`参数来进行下载。例如,执行以下命令下载Docker的安装包到指定目录:
```
yum -y install --downloadonly --downloaddir=/root/docker docker-ce
```
其中,`--downloaddir`参数指定了下载后的路径,`docker-ce`是Docker的服务名。<span class="em">1</span><span class="em">2</span><span class="em">3</span>
#### 引用[.reference_title]
- *1* [离线装docker和相关应用保姆级教程——以安装docker-jupyter/notebook为例](https://blog.csdn.net/qq_37150711/article/details/131041560)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *2* [离线安装docker运行环境的曲折过程](https://blog.csdn.net/seawaving/article/details/123529906)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
- *3* [Linux离线安装Docker](https://blog.csdn.net/vippomelo/article/details/120762409)[target="_blank" data-report-click={"spm":"1018.2226.3001.9630","extra":{"utm_source":"vip_chatgpt_common_search_pc_result","utm_medium":"distribute.pc_search_result.none-task-cask-2~all~insert_cask~default-1-null.142^v92^chatsearchT3_1"}}] [.reference_item style="max-width: 33.333333333333336%"]
[ .reference_list ]
阅读全文