实在搞不定可以用https://labs.play-with-docker.com/ 来玩玩就好了。
今天我打算练习docker,但还不影响MacOS的纯净性 计划使用虚拟机的方式进行练习,
结构如下,Mac -> vagrant -> VirtualBox Cent 7 -> Docker
这样做的目的是实验环境随时可一键删除,不影响使用的系统,
隔离了用户系统的影响,
不管是windows 还是 Mac 得到的演示结果是一致的
https://www.virtualbox.org/wiki/Downloads
https://www.vagrantup.com/downloads.html
找到自己操作系统的版本
下载安装就不在这里详述了
AlbertMP:~ Albert$ vagrant
Usage: vagrant [options] <command> [<args>]
-v, --version Print the version and exit.
-h, --help Print this help.
Common commands:
box manages boxes: installation, removal, etc.
cloud manages everything related to Vagrant Cloud
destroy stops and deletes all traces of the vagrant machine
global-status outputs status Vagrant environments for this user
halt stops the vagrant machine
help shows the help for a subcommand
init initializes a new Vagrant environment by creating a Vagrantfile
login
package packages a running vagrant environment into a box
plugin manages plugins: install, uninstall, update, etc.
port displays information about guest port mappings
powershell connects to machine via powershell remoting
provision provisions the vagrant machine
push deploys code in this environment to a configured destination
rdp connects to machine via RDP
reload restarts vagrant machine, loads new Vagrantfile configuration
resume resume a suspended vagrant machine
snapshot manages snapshots: saving, restoring, etc.
ssh connects to machine via SSH
ssh-config outputs OpenSSH valid configuration to connect to the machine
status outputs status of the vagrant machine
suspend suspends the machine
up starts and provisions the vagrant environment
upload upload to machine via communicator
validate validates the Vagrantfile
version prints current and latest Vagrant version
winrm executes commands on a machine via WinRM
winrm-config outputs WinRM configuration to connect to the machine
For help on any individual command run `vagrant COMMAND -h`
Additional subcommands are available, but are either more advanced
or not commonly used. To see all subcommands, run the command
`vagrant list-commands`.
# 创建一个目
mkdir -p ~/coding/docker/centos7
# 移动到当前目录
cd ~/coding/docker/centos7
# 查看当前目录
pwd
# 初始化一个centos/7
vagrant init centos/7
# 查看Vagrant 配置
more Vagrantfile
# 启动
vagrant up
# 登陆刚刚创建好了的 centos
vagrant ssh
https://docs.docker.com/install/linux/docker-ce/centos/#prerequisites
1 hostname
2 ip addr
3 exit
4 ll
5 sudo yum update
6 exit
7 sudo yum remove docker docker-client docker-client-latest docker-common docker-latest docker-latest-logrotate docker-logrotate docker-engine
8 sudo yum install -y yum-utils device-mapper-persistent-data lvm2
9 sudo yum-config-manager --add-repo https://download.docker.com/linux/centos/docker-ce.repo
10 sudo yum install docker-ce docker-ce-cli containerd.io
15 sudo systemctl start docker
16 sudo docker run hello-world
17 history
至此Docker就安装完成了
扫码关注腾讯云开发者
领取腾讯云代金券
Copyright © 2013 - 2025 Tencent Cloud. All Rights Reserved. 腾讯云 版权所有
深圳市腾讯计算机系统有限公司 ICP备案/许可证号:粤B2-20090059 深公网安备号 44030502008569
腾讯云计算(北京)有限责任公司 京ICP证150476号 | 京ICP备11018762号 | 京公网安备号11010802020287
Copyright © 2013 - 2025 Tencent Cloud.
All Rights Reserved. 腾讯云 版权所有