时间:2021-05-19
Docker是一个开源的引擎,可以轻松的为任何应用创建一个轻量级的、可移植的、自给自足的容器。
开发者在笔记本上编译测试通过的容器可以批量地在生产环境中部署,包括VMs(虚拟机)、bare metal、OpenStack集群和其他的基础应用平台。
Docker的源代码全部是用Go语言写的。
一、基础环境
1、角色、ip、版本、内核
serverA 10.1.10.236 3.16.0-4-amd64 8.1 docket
docket 1.6.2
二、安装docter
1、添加源
echo "deb http://http.debian.net/debian jessie-backports main" >> /etc/apt/sources.list
2、更新源
apt-get update
3、安装docker.io包
apt-get install docker.ioReading package lists... DoneBuilding dependency tree Reading state information... DoneThe following extra packages will be installed:aufs-tools cgroupfs-mount git git-man libapparmor1 liberror-perl libnih-dbus1 libnih1 makedev mountall plymouthSuggested 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-baseplymouth-themesThe following NEW packages will be installed:aufs-tools cgroupfs-mount docker.io git git-man libapparmor1 liberror-perl libnih-dbus1 libnih1 makedev mountall plymouth0 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、查看版本
docker --versionDocker version 1.6.2, build 7c8fca25、启动服务
/etc/init.d/docker start[ ok ] Starting docker (via systemctl): docker.service.6、拉取debian和CentOS镜像
1)拉取debian镜像
docker pull debianlatest: Pulling from debian843e2bded498: 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:d9168a2c1889b4c9d44952a23065c29b0656237909d618328275f42065602354Status: Downloaded newer image for debian:latest2)拉取centos镜像
docker pull centosPulling repository centos0f73ae75014f: Download complete 47d44cb6f252: Download complete f6f39725d938: Download complete f9a8cbc8dd13: Download complete f37e6a610a37: Download complete Status: Downloaded newer image for centos:latest7、查看镜像
docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEdebian latest 8c00acfb0175 3 weeks ago 125.2 MBcentos latest 0f73ae75014f 3 weeks ago 172.3 MB8、运行名为debian镜像的容器(虚拟
docker imagesREPOSITORY TAG IMAGE ID CREATED VIRTUAL SIZEdebian latest 8c00acfb0175 3 weeks ago 125.2 MBcentos latest 0f73ae75014f 3 weeks ago 172.3 MB出1个debian系统)
1)运行debian镜像的容器
docker run -i -t debian2)查看版本
root@10.1.10.236:~# docker run debian cat /etc/debian_version8.23)查看IP(是dhcp获得 每次获得都不一样)
root@10.1.10.236:~# docker run debian ip a1: 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:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever24: 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:ffinet 172.17.0.11/16 scope global eth0valid_lft forever preferred_lft foreverinet6 fe80::42:acff:fe11:b/64 scope link tentative valid_lft forever preferred_lft forever4)查看内核
root@10.1.10.236:~# docker run debian uname -r3.16.0-4-amd645)查看硬盘分区情况
root@10.1.10.236:~# docker run -i -t debian df -ThFilesystem Type Size Used Avail Use% Mounted onnone aufs 9.1G 1.6G 7.1G 18% /tmpfs tmpfs 115M 0 115M 0% /devshm tmpfs 64M 0 64M 0% /dev/shm/dev/sda1 ext4 9.1G 1.6G 7.1G 18% /etc/hosts9、运行名为centos镜像的容器(虚拟出1个centos系统)
1)运行centos镜像的容器
docker run -i -t centos2)查看版本
root@10.1.10.236:~# docker run centos cat /etc/RedHat-releaseCentOS Linux release 7.1.1503 (Core)3)查看内核
root@10.1.10.236:~# docker run centos uname -r3.16.0-4-amd644)查看ip
root@10.1.10.236:~# docker run centos ip a1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00inet 127.0.0.1/8 scope host lovalid_lft forever preferred_lft foreverinet6 ::1/128 scope host valid_lft forever preferred_lft forever46: eth0: <NO-CARRIER,BROADCAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state DOWN link/ether 02:42:ac:11:00:16 brd ff:ff:ff:ff:ff:ffinet 172.17.0.22/16 scope global eth0valid_lft forever preferred_lft foreverinet6 fe80::42:acff:fe11:16/64 scope link tentative valid_lft forever preferred_lft forever5)查看硬盘分区情况
root@10.1.10.236:~# docker run centos df -ThFilesystem Type Size Used Avail Use% Mounted onrootfs rootfs 9.1G 1.6G 7.1G 18% /none aufs 9.1G 1.6G 7.1G 18% /tmpfs tmpfs 115M 0 115M 0% /devshm tmpfs 64M 0 64M 0% /dev/shm/dev/sda1 ext4 9.1G 1.6G 7.1G 18% /etc/hoststmpfs tmpfs 115M 0 115M 0% /proc/kcoretmpfs tmpfs 115M 0 115M 0% /proc/timer_stats以上所述是小编给大家介绍的Linux下Docker安装和使用教程,希望对大家有所帮助,如果大家有任何疑问欢迎给我留言!
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
在之前的文章中我们有介绍过Docker的安装,不少朋友在安装后不知要如何使用Docker容器,下面小编就给大家介绍下Linux如何使用Docker容器。
Requirements最近学习了下kafka,为方便搭建环境,使用docker进行部署。需要首先安装docker的环境。要求操作系统是linux的64位系统。
大家好,今天我们来了解一下Windows操作系统中的Docker以及在其中安装DockerWindows客户端的知识。Docker引擎使用Linux特有的内核特
参考文档官方Docker安装文档:https://docs.docker.com/install/linux/docker-ce/centos阿里云Docker
centos7安装docker一、官网安装指南地址https://docs.docker.com/engine/installation/linux/cento