Installation and use of docker under windows

Since the daemon of the Docker engine uses the Linux kernel, a virtual machine needs to be borrowed.
The installation of docker under windows is also divided into win10 professional edition (supporting Hyper-V) and non-win10 professional edition (not supporting Hyper-V).
Hyper-V view method: Control Panel -> Programs and Features -> Enable or disable windows function -> Whether there is Hyper-V function.
If you support Hyper-V, check it, you should go directly to the official download and install the installation package.
My computer itself is win8, after the upgrade, it is win10 home version, it does not support Hyper-V, and a virtual machine is required. Docker toolbox contains this series of tools, so I introduce the docker toolbox method.

One, download docker toolbox

Enter http://mirrors.aliyun.com/docker-toolbox/windows/docker-toolbox/ download the latest version and enter the installation.
Insert picture description here
The default is fine. After the installation is complete, 3 icons will be generated on the desktop.
Insert picture description here

  1. Docker QuickStart shell This is a command line environment with Docker already configured
  2. Oracle VM Virtualbox virtual machine software (actually the same as VMware, if you have used it)
  3. Kitematic. This is the GUI version of Docker (If you don’t need this, you can uncheck it during installation)

Two, start

Click the Docker QuickStart icon to start the Docker Toolbox terminal. The first startup will be slow, so wait patiently...
Insert picture description here
Finally, the cute little whale appears, and the installation is successful.
Here is generated IP 192.168.99.100 remember.

Three, use Xshell to connect (can be ignored)

Why use a shell? Because I just want to lose one icon. Yes, Xshell is what I often use. Since it can replace Docker QuickStart shell, I can delete this icon. Including the original VMware on my computer, since there is Oracle VM Virtualbox and it is open source, I would consider replacing it. I have not installed the Kitematic above.

Xshell creates a connection, the host IP is 192.168.99.100, the default username is docker, and the password is tcuser.
Insert picture description here
Then start or shut down, through Oracle VM Virtualbox.
It should be noted that, in order not to generate a window, use "no interface start" when starting, this option does not display the start-up process, my computer has to wait for 1 minute, and then connect to Xshell
Insert picture description here

Four, mirroring command

command Features
docker search [mirror name] Search related mirrors
docker pull [image name] Load the image and automatically generate the warehouse
docker images View all local mirrors
docker tag [Mirror ID] [Warehouse: new tag name] Add a new label to the mirror
docker rmi $(docker images -q) Delete all local mirrors

Five, container commands

command Features
docker run [mirror] [script] Generate the container and run the script
                     -d Background process
                     -P The internal port of the container is randomly mapped to the high port of the host
                     -p 5001:5000 Bind the internal port of the container to the specified host port
                     --name mytest Named mytest
docker ps View the running container
docker ps -a View all containers
docker ps -l Query the last container created
docker stop [container name|container ID] Stop container
docker stop $(docker ps) Stop all containers
docker start [container name | container ID] Start the container
docker restart [container name|container ID] Restart the specified container
docker rm [container name|container ID] Remove stopped container
docker rm $(docker ps -a) Remove container
docker port [container name|container ID] View port
docker logs [container name|container ID] View log
docker top [container name|container ID] View the processes running inside the container
docker exec -it [container name|container ID] /bin/bash Into the container
docker commit -m="description" -a="author" [container name|container ID] [warehouse: label] Create a new image from the container

Six, examples

docker pull training/webappPull test image

docker imagesView mirror
Insert picture description here

docker run -d -p 5001:5000 --name mytest training/webapp python app.pyRun the container to Insert picture description here
docker psview the running container
Insert picture description here
CONTAINER ID is "container ID"
NAMES is "container name"

It is more convenient to use the container name during operation, because the container name can be customized and can be automatically completed by the Tab key, and the container ID cannot be automatically completed by the Tab key.

Guess you like

Origin blog.csdn.net/z772532526/article/details/86674592