In the previous article, we introduced the installation of Docker (see How to install Docker in CentOS 6.5 system). Many friends don't know how to use Docker container after installation. Everyone introduces how Linux uses Docker containers.
1. Start a Docker container
[root @ localhost ~] # docker run -i -t Ubuntu /bin /bash
Unable to find image & lsquo ;ubuntu’ locally
Pulling repository ubuntu
04c5d3b7b065: Download complete
511136ea3c5a: Download complete
c7b7c6419568: Download complete
70c8faa62a44 : Download complete
d735006ad9c1: Download complete
Status: Downloaded newer image for ubuntu:latest
Note:
-i: Open STDIN in the container
-t: Assign a pseudo tty terminal to the container
From the above we can see that Docker will first check if there is a ubuntu image locally. If the image is not found locally, then Docker Go to the official Docker Hub Registry to see if there is this image in the Docker Hub. Once Docker finds the image, it downloads the image and saves it to the local host.
Then, Docker creates a new container with this image inside the file system. The container has its own network, IP address, and a bridged network interface that can be used to communicate with the host. Finally, we tell Docker what commands to run in the new container.
When the container is created, Docker executes the /bin/bash command in the container. At this time we can see the shell inside the container
root@8c342c0c275c:/#
Note: 8c342c0c275c represents the ID of the container
2.Use the container
View the host name of the container
root@8c342c0c275c:/# hostname
8c342c0c275c
As you can see, the host name of the container is the ID of the container
View the host's hosts file
root@8c342c0c275c:/# cat /etc/hosts
172.17.0.2 8c342c0c275c
ff00::0 ip6-mcastprefix< Br>
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
127.0.0.1 localhost
::1 localhost ip6-localhost ip6- Loopback
fe00::0 ip6-localnet
You can see that Docker has added a host configuration item to the container's IP address.
View the IP address of the container
root@8c342c0c275c:/# ip a
1: lo: "LOOPBACK, UP, LOWER_UP" mtu 65536 qdisc noqueue state UNKNOWN group Default
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
valid_lft forever preferred_lft forever
inet6 ::1/128 scope host
valid_lft forever preferred_lft forever
4: eth0: "BROADCAST,UP,LOWER_UP" mtu 1500 qdisc pfifo_fast state UP group default qlen 1000
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ffp:fp=inp 172.17. 0.2/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:2/64 scope link
valid_lft forever preferred_lft forever
Previous123Next page Total 3 pages
In many cases, Linux is used as a server to allow computers on the Internet to acce
Microsoft system process management, can not open the task manager, view the process, end the proces
OpenWRT is an embedded Linux system. Friends who want to understand the embedded Linux system are bl
Because Ubuntu is a multi-user operating system, so often need to create and add new users, the foll
What should I do if Ubuntu prompts the list error when opening the software center?
How Linux can view the number of 80 port connections through the netstat command
Tips for learning Linux system commands
Ubuntu10.10 configuration R environment method
RedHat software source prompt Unable to read consumer identity?
Linux how to set up git to share with svn
Linux using the fdisk tool to create partitions
Linux replacement hard disk has been mounted directory skills
Steps to install Tmux software on CentOS
Linux boot error report to disable selinux policy?
Computer Technology: Win8.1 efficiently manages applications
Win8 system blue screen failure 0x00000050 error code phenomenon solution detailed
If the system does not automatically prompt to upgrade Win8.1 how to manually upgrade
How to change the win7 disk drive? Win7 change the drive letter method to share
How to solve the problem that Win10 does not have a start menu?
Chkdsk disk repair tool method
Install nginx php7 under linux