The mounting docker [by Vagrant + Virtualbox => Centos]

1 Overview

1.我这里使用的电脑是本地的mac系统
2.因为我现在需要弄一台centos的linux服务器,所以我们这里使用vagrant去生成一个centso的linux的系统环境;
3.在vagrant去生成系统环境的过程中,需要提前安装一个VirtualBox

2.vagrant installation

vagrant Download

https://www.vagrantup.com/downloads.html
various versions
Here Insert Picture Description

Mounting

Has been directly down to the point, the default configuration installation

Test whether the installation is successful

Here Insert Picture Description
Display version means that the installation was successful

vagrant commonly used commands

vagrant ssh

	进入刚才创建的centos7中

vagrant status

	查看centos7的状态

vagrant halt

	停止/关闭centos7

vagrant destroy

	删除centos7

vagrant status

查看状态

vagrant help help

MacBook-Pro:centos7 gaoxinfu$ vagrant help
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`.

MacBook-Pro:centos7 gaoxinfu$ 

3.VirtualBox installation

download

https://www.virtualbox.org/wiki/Downloads

version as related systems

installation

Installation has to default

After the installation is completed successfully as follows

Here Insert Picture Description

4.centos system installation

Initialization vagrant

MacBook-Pro:docker gaoxinfu$ pwd
/Users/gaoxinfu/docker
MacBook-Pro:docker gaoxinfu$ makdir centos/7
MacBook-Pro:docker gaoxinfu$ ll
total 24
drwxr-xr-x   5 gaoxinfu  staff    160 11  8 15:24 ./
drwxr-xr-x@ 66 gaoxinfu  staff   2112 11 12 13:55 ../
drwxr-xr-x   4 gaoxinfu  staff    128 11  8 15:26 centos7/
MacBook-Pro:docker gaoxinfu$ 
MacBook-Pro:docker gaoxinfu$ cd centos7/
MacBook-Pro:centos7 gaoxinfu$ pwd
/Users/gaoxinfu/docker/centos7
MacBook-Pro:centos7 gaoxinfu$ 

Start initialization

MacBook-Pro:centos7 gaoxinfu$ vagrant init centos/7

Vagrantfile will generate a file in the current directory after bin

MacBook-Pro:centos7 gaoxinfu$ pwd
/Users/gaoxinfu/docker/centos7
MacBook-Pro:centos7 gaoxinfu$ ls
Vagrantfile
MacBook-Pro:centos7 gaoxinfu$ 

Vagrant by initializing the image centos7

Download virtualbox image of centos7

Baidu

Link: https: //pan.baidu.com/s/1Cusm2nZ3xI7p6danMFfrDw Password: p08y

Note here under our virtualbox.box is our guide out of the VirtualBox scene;

Add Mirror by Vagrant

MacBook-Pro:image gaoxinfu$ pwd
/Users/gaoxinfu/docker/image
MacBook-Pro:image gaoxinfu$ ls
virtualbox.box
MacBook-Pro:image gaoxinfu$ 
MacBook-Pro:centos7 gaoxinfu$ pwd
/Users/gaoxinfu/docker/centos7
MacBook-Pro:centos7 gaoxinfu$ vagrant box add centos/7 /Users/gaoxinfu/docker/centos7/virtualbox.box
MacBook-Pro:image gaoxinfu$ vagrant box list
centos/7 (virtualbox, 0)

5.docker installation

5.1. Start vagrant [vagrant up]

MacBook-Pro:centos7 gaoxinfu$ pwd
/Users/gaoxinfu/docker/centos7
MacBook-Pro:centos7 gaoxinfu$ vagrant ssh
VM must be running to open SSH connection. Run `vagrant up`
to start the virtual machine.
MacBook-Pro:centos7 gaoxinfu$ vagrant up
Bringing machine 'default' up with 'virtualbox' provider...
==> default: Clearing any previously set forwarded ports...
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
==> default: Forwarding ports...
    default: 22 (guest) => 2222 (host) (adapter 1)
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
    default: No guest additions were detected on the base box for this VM! Guest
    default: additions are required for forwarded ports, shared folders, host only
    default: networking, and more. If SSH fails on this machine, please install
    default: the guest additions and repackage the box to continue.
    default: 
    default: This is not an error message; everything may continue to work properly,
    default: in which case you may ignore this message.
==> default: Rsyncing folder: /Users/gaoxinfu/docker/centos7/ => /vagrant
==> default: Machine already provisioned. Run `vagrant provision` or use the `--provision`
==> default: flag to force provisioning. Provisioners marked to run always will still run.
MacBook-Pro:centos7 gaoxinfu$ 

5.2. Centos landing system we installed through vagrant command

MacBook-Pro:centos7 gaoxinfu$ vagrant ssh
[vagrant@localhost ~]$ 

5.3. Centos system mounted in the docker

Uninstall docker

[vagrant@localhost ~]$ sudo yum remove docker \
>                   docker-client \
>                   docker-client-latest \
>                   docker-common \
>                   docker-latest \
>                   docker-latest-logrotate \
>                   docker-logrotate \
>                   docker-engine

Installation depends Docker's

[vagrant@localhost ~]$ sudo yum install -y yum-utils \
>     device-mapper-persistent-data \
>     lvm2

Specify what Docker warehouse

[vagrant@localhost ~]$ sudo yum-config-manager \
      --add-repo \
      https://download.docker.com/linux/centos/docker-ce.repo

Here Insert Picture Description

start installation

[vagrant@localhost ~]$ sudo yum install -y docker-ce docker-ce-cli containerd.io

Here Insert Picture Description
This installation is complete

5.4. Started

[vagrant@localhost ~]$ sudo systemctl start docker

Here Insert Picture Description
Note here under \ slash in linux command line to change the meaning of which is, we pay attention to the next;

5.5 Test docker successfully installed

[vagrant@localhost ~]$ sudo docker run hello-world

Here Insert Picture Description

Published 261 original articles · won praise 37 · Views 200,000 +

Guess you like

Origin blog.csdn.net/u014636209/article/details/103052261