Linux Docker installation and use tutorial
- 2020-05-17 07:06:12
- OfStack
Docker is an open source engine that makes it easy to create a lightweight, portable, self-contained container for any application.
Containers that developers compile and test on their laptops can be deployed in bulk in production environments, including VMs(virtual machine), bare metal, OpenStack clusters, and other basic application platforms.
Docker source code is all written in Go language.
1. Basic environment
1. Role, ip, version, kernel
serverA 10.1.10.236 3.16.0-4-amd64 8.1 docket
docket 1.6.2
2. Install docter
1. Add sources
echo "deb http://http.debian.net/debian jessie-backports main"
>
>
/etc/apt/sources.list
2. Update the source
apt-get update
3. Install the docker.io package
apt-get install docker.io
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following extra packages will be installed:
aufs-tools cgroupfs-mount git git-man libapparmor1 liberror-perl libnih-dbus1 libnih1 makedev mountall plymouth
Suggested packages:
btrfs-tools debootstrap lxc rinse git-daemon-run git-daemon-sysvinit git-doc git-el git-email git-gui gitk gitweb git-arch git-cvs git-mediawiki git-svn desktop-base
plymouth-themes
The following NEW packages will be installed:
aufs-tools cgroupfs-mount docker.io git git-man libapparmor1 liberror-perl libnih-dbus1 libnih1 makedev mountall plymouth
0 upgraded, 12 newly installed, 0 to remove and 54 not upgraded.
Need to get 9,986 kB of archives.
After this operation, 47.2 MB of additional disk space will be used.
Do you want to continue? [Y/n]
4. View the version
docker --version
Docker version 1.6.2, build 7c8fca2
5. Start the service
/etc/init.d/docker start
[ ok ] Starting docker (via systemctl): docker.service.
6. Pull debian and CentOS images
1) pull debian image
docker pull debian
latest: Pulling from debian
843e2bded498: Pull complete
8c00acfb0175: Pull complete
debian:latest: The image you are pulling has been verified. Important: image verification is a tech preview feature and should not be relied on to provide security.
Digest: sha256:d9168a2c1889b4c9d44952a23065c29b0656237909d618328275f42065602354
Status: Downloaded newer image for debian:latest
2) pull the centos image
docker pull centos
Pulling repository centos
0f73ae75014f: Download complete
47d44cb6f252: Download complete
f6f39725d938: Download complete
f9a8cbc8dd13: Download complete
f37e6a610a37: Download complete
Status: Downloaded newer image for centos:latest
7. View the mirror
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
debian latest 8c00acfb0175 3 weeks ago 125.2 MB
centos latest 0f73ae75014f 3 weeks ago 172.3 MB
8. Run the container (virtual) named debian image
docker images
REPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZE
debian latest 8c00acfb0175 3 weeks ago 125.2 MB
centos latest 0f73ae75014f 3 weeks ago 172.3 MB
Produce one debian system)
1) run the debian mirrored container
docker run -i -t debian
2) view the version
root@10.1.10.236:~# docker run debian cat /etc/debian_version
8.2
3) view IP(it is dhcp that gets one at a time)
root@10.1.10.236:~# docker run debian 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
24: eth0: <NO-CARRIER,BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state DOWN group default
link/ether 02:42:ac:11:00:0b brd ff:ff:ff:ff:ff:ff
inet 172.17.0.11/16 scope global eth0
valid_lft forever preferred_lft forever
inet6 fe80::42:acff:fe11:b/64 scope link tentative
valid_lft forever preferred_lft forever
4) look at the kernel
docker --version
Docker version 1.6.2, build 7c8fca2
0
5) check hard disk partitioning
docker --version
Docker version 1.6.2, build 7c8fca2
1
9. Run the container named centos mirror (make a virtual centos system)
1) run the centos mirrored container
docker --version
Docker version 1.6.2, build 7c8fca2
2
2) view the version
root@10.1.10.236:~# docker run centos cat /etc/RedHat-release
CentOS Linux release 7.1.1503 (Core)
3) look at the kernel
docker --version
Docker version 1.6.2, build 7c8fca2
4
4) check ip
docker --version
Docker version 1.6.2, build 7c8fca2
5
5) check hard disk partitioning
docker --version
Docker version 1.6.2, build 7c8fca2
6
The above is the site to introduce you Linux Docker installation and use of the tutorial, I hope to help you, if you have any questions please leave me a message!