【Docker】进阶之路:(四)操作容器
【Docker】进阶之路:(四)操作容器
容器的生命周期
容器的生命周期分为五种状态,分别为:
- Created:初建状态,表示容器已经被创建,容器所需的相关资源已经准备就绪,但容器中的程序还未处于运行状态。
- Running:运行状态,表示容器正在运行,也就是容器中的应用正在运行。
- Paused:暂停状态,表示容器已暂停,表示容器中的所有程序都处于暂停(不是停止)状态。
- Stopped:停止状态,表示容器处于停止状态,占用的资源和沙盒环境都依然存在,只是容器中的应用程序均已停止。
- Deleted:删除状态,表示容器已删除,相关占用的资源及存储在 Docker 中的管理信息也都已释放和移除。
创建容器
容器是Docker提供网络服务的主体。为了能够提供MySQL、Apache等网络服务,用户必须创建对应的容器。
在Docker中,用户可以通过两种方式来创建容器。
docker create
[root@docker ~]# docker create --help
Usage: docker create [OPTIONS] IMAGE [COMMAND] [ARG...]
Create a new container
Aliases:
docker container create, docker create
Options:
--add-host list Add a custom host-to-IP mapping (host:ip)
--annotation map Add an annotation to the container (passed through to the OCI runtime) (default map[])
-a, --attach list Attach to STDIN, STDOUT or STDERR
--blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
--blkio-weight-device list Block IO weight (relative device weight) (default [])
--cap-add list Add Linux capabilities
--cap-drop list Drop Linux capabilities
--cgroup-parent string Optional parent cgroup for the container
--cgroupns string Cgroup namespace to use (host|private)
'host': Run the container in the Docker host's cgroup namespace
'private': Run the container in its own private cgroup namespace
'': Use the cgroup namespace as configured by the
default-cgroupns-mode option on the daemon (default)
--cidfile string Write the container ID to the file
--cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
--cpu-rt-period int Limit CPU real-time period in microseconds
--cpu-rt-runtime int Limit CPU real-time runtime in microseconds
-c, --cpu-shares int CPU shares (relative weight)
--cpus decimal Number of CPUs
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
--device list Add a host device to the container
--device-cgroup-rule list Add a rule to the cgroup allowed devices list
--device-read-bps list Limit read rate (bytes per second) from a device (default [])
--device-read-iops list Limit read rate (IO per second) from a device (default [])
--device-write-bps list Limit write rate (bytes per second) to a device (default [])
--device-write-iops list Limit write rate (IO per second) to a device (default [])
--disable-content-trust Skip image verification (default true)
--dns list Set custom DNS servers
--dns-option list Set DNS options
--dns-search list Set custom DNS search domains
--domainname string Container NIS domain name
--entrypoint string Overwrite the default ENTRYPOINT of the image
-e, --env list Set environment variables
--env-file list Read in a file of environment variables
--expose list Expose a port or a range of ports
--gpus gpu-request GPU devices to add to the container ('all' to pass all GPUs)
--group-add list Add additional groups to join
--health-cmd string Command to run to check health
--health-interval duration Time between running the check (ms|s|m|h) (default 0s)
--health-retries int Consecutive failures needed to report unhealthy
--health-start-period duration Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
--health-timeout duration Maximum time to allow one check to run (ms|s|m|h) (default 0s)
--help Print usage
-h, --hostname string Container host name
--init Run an init inside the container that forwards signals and reaps processes
-i, --interactive Keep STDIN open even if not attached
--ip string IPv4 address (e.g., 172.30.100.104)
--ip6 string IPv6 address (e.g., 2001:db8::33)
--ipc string IPC mode to use
--isolation string Container isolation technology
--kernel-memory bytes Kernel memory limit
-l, --label list Set meta data on a container
--label-file list Read in a line delimited file of labels
--link list Add link to another container
--link-local-ip list Container IPv4/IPv6 link-local addresses
--log-driver string Logging driver for the container
--log-opt list Log driver options
--mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33)
-m, --memory bytes Memory limit
--memory-reservation bytes Memory soft limit
--memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
--mount mount Attach a filesystem mount to the container
--name string Assign a name to the container
--network network Connect a container to a network
--network-alias list Add network-scoped alias for the container
--no-healthcheck Disable any container-specified HEALTHCHECK
--oom-kill-disable Disable OOM Killer
--oom-score-adj int Tune host's OOM preferences (-1000 to 1000)
--pid string PID namespace to use
--pids-limit int Tune container pids limit (set -1 for unlimited)
--platform string Set platform if server is multi-platform capable
--privileged Give extended privileges to this container
-p, --publish list Publish a container's port(s) to the host
-P, --publish-all Publish all exposed ports to random ports
--pull string Pull image before creating ("always", "|missing", "never") (default "missing")
-q, --quiet Suppress the pull output
--read-only Mount the container's root filesystem as read only
--restart string Restart policy to apply when a container exits (default "no")
--rm Automatically remove the container when it exits
--runtime string Runtime to use for this container
--security-opt list Security Options
--shm-size bytes Size of /dev/shm
--stop-signal string Signal to stop the container
--stop-timeout int Timeout (in seconds) to stop a container
--storage-opt list Storage driver options for the container
--sysctl map Sysctl options (default map[])
--tmpfs list Mount a tmpfs directory
-t, --tty Allocate a pseudo-TTY
--ulimit ulimit Ulimit options (default [])
-u, --user string Username or UID (format: <name|uid>[:<group|gid>])
--userns string User namespace to use
--uts string UTS namespace to use
-v, --volume list Bind mount a volume
--volume-driver string Optional volume driver for the container
--volumes-from list Mount volumes from the specified container(s)
-w, --workdir string Working directory inside the container
[root@docker ~]#
docker run
[root@docker ~]# docker run --help
Usage: docker run [OPTIONS] IMAGE [COMMAND] [ARG...]
Create and run a new container from an image
Aliases:
docker container run, docker run
Options:
--add-host list Add a custom host-to-IP mapping (host:ip)
--annotation map Add an annotation to the container (passed through to the OCI runtime) (default map[])
-a, --attach list Attach to STDIN, STDOUT or STDERR
--blkio-weight uint16 Block IO (relative weight), between 10 and 1000, or 0 to disable (default 0)
--blkio-weight-device list Block IO weight (relative device weight) (default [])
--cap-add list Add Linux capabilities
--cap-drop list Drop Linux capabilities
--cgroup-parent string Optional parent cgroup for the container
--cgroupns string Cgroup namespace to use (host|private)
'host': Run the container in the Docker host's cgroup namespace
'private': Run the container in its own private cgroup namespace
'': Use the cgroup namespace as configured by the
default-cgroupns-mode option on the daemon (default)
--cidfile string Write the container ID to the file
--cpu-period int Limit CPU CFS (Completely Fair Scheduler) period
--cpu-quota int Limit CPU CFS (Completely Fair Scheduler) quota
--cpu-rt-period int Limit CPU real-time period in microseconds
--cpu-rt-runtime int Limit CPU real-time runtime in microseconds
-c, --cpu-shares int CPU shares (relative weight)
--cpus decimal Number of CPUs
--cpuset-cpus string CPUs in which to allow execution (0-3, 0,1)
--cpuset-mems string MEMs in which to allow execution (0-3, 0,1)
-d, --detach Run container in background and print container ID
--detach-keys string Override the key sequence for detaching a container
--device list Add a host device to the container
--device-cgroup-rule list Add a rule to the cgroup allowed devices list
--device-read-bps list Limit read rate (bytes per second) from a device (default [])
--device-read-iops list Limit read rate (IO per second) from a device (default [])
--device-write-bps list Limit write rate (bytes per second) to a device (default [])
--device-write-iops list Limit write rate (IO per second) to a device (default [])
--disable-content-trust Skip image verification (default true)
--dns list Set custom DNS servers
--dns-option list Set DNS options
--dns-search list Set custom DNS search domains
--domainname string Container NIS domain name
--entrypoint string Overwrite the default ENTRYPOINT of the image
-e, --env list Set environment variables
--env-file list Read in a file of environment variables
--expose list Expose a port or a range of ports
--gpus gpu-request GPU devices to add to the container ('all' to pass all GPUs)
--group-add list Add additional groups to join
--health-cmd string Command to run to check health
--health-interval duration Time between running the check (ms|s|m|h) (default 0s)
--health-retries int Consecutive failures needed to report unhealthy
--health-start-period duration Start period for the container to initialize before starting health-retries countdown (ms|s|m|h) (default 0s)
--health-timeout duration Maximum time to allow one check to run (ms|s|m|h) (default 0s)
--help Print usage
-h, --hostname string Container host name
--init Run an init inside the container that forwards signals and reaps processes
-i, --interactive Keep STDIN open even if not attached
--ip string IPv4 address (e.g., 172.30.100.104)
--ip6 string IPv6 address (e.g., 2001:db8::33)
--ipc string IPC mode to use
--isolation string Container isolation technology
--kernel-memory bytes Kernel memory limit
-l, --label list Set meta data on a container
--label-file list Read in a line delimited file of labels
--link list Add link to another container
--link-local-ip list Container IPv4/IPv6 link-local addresses
--log-driver string Logging driver for the container
--log-opt list Log driver options
--mac-address string Container MAC address (e.g., 92:d0:c6:0a:29:33)
-m, --memory bytes Memory limit
--memory-reservation bytes Memory soft limit
--memory-swap bytes Swap limit equal to memory plus swap: '-1' to enable unlimited swap
--memory-swappiness int Tune container memory swappiness (0 to 100) (default -1)
--mount mount Attach a filesystem mount to the container
--name string Assign a name to the container
--network network Connect a container to a network
--network-alias list Add network-scoped alias for the container
--no-healthcheck Disable any container-specified HEALTHCHECK
--oom-kill-disable Disable OOM Killer
--oom-score-adj int Tune host's OOM preferences (-1000 to 1000)
--pid string PID namespace to use
--pids-limit int Tune container pids limit (set -1 for unlimited)
--platform string Set platform if server is multi-platform capable
--privileged Give extended privileges to this container
-p, --publish list Publish a container's port(s) to the host
-P, --publish-all Publish all exposed ports to random ports
--pull string Pull image before running ("always", "missing", "never") (default "missing")
-q, --quiet Suppress the pull output
--read-only Mount the container's root filesystem as read only
--restart string Restart policy to apply when a container exits (default "no")
--rm Automatically remove the container when it exits
--runtime string Runtime to use for this container
--security-opt list Security Options
--shm-size bytes Size of /dev/shm
--sig-proxy Proxy received signals to the process (default true)
--stop-signal string Signal to stop the container
--stop-timeout int Timeout (in seconds) to stop a container
--storage-opt list Storage driver options for the container
--sysctl map Sysctl options (default map[])
--tmpfs list Mount a tmpfs directory
-t, --tty Allocate a pseudo-TTY
--ulimit ulimit Ulimit options (default [])
-u, --user string Username or UID (format: <name|uid>[:<group|gid>])
--userns string User namespace to use
--uts string UTS namespace to use
-v, --volume list Bind mount a volume
--volume-driver string Optional volume driver for the container
--volumes-from list Mount volumes from the specified container(s)
-w, --workdir string Working directory inside the container
[root@docker ~]#
管理容器
使用Docker一段时间后,计算机上或许会有许多云心和非运行的容器。
[root@docker ~]# docker ps --help
Usage: docker ps [OPTIONS]
List containers
Aliases:
docker container ls, docker container list, docker container ps, docker ps
Options:
-a, --all Show all containers (default shows just running)
-f, --filter filter Filter output based on conditions provided
--format string Format output using a custom template:
'table': Print output in table format with column headers (default)
'table TEMPLATE': Print output in table format using the given Go template
'json': Print in JSON format
'TEMPLATE': Print output using the given Go template.
Refer to https://docs.docker.com/go/formatting/ for more information about formatting output with templates
-n, --last int Show n last created containers (includes all states) (default -1)
-l, --latest Show the latest created container (includes all states)
--no-trunc Don't truncate output
-q, --quiet Only display container IDs
-s, --size Display total file sizes
[root@docker ~]#
查看运行的容器:
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker ~]#
查看所有容器:
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker ~]#
启动与终止
启动容器
容器是交互式的,有点类似于虚拟机,且更加有利于资源的高效利用。例如,使用Ubuntu的最新镜像运行一个容器。-i和-t子命令的意思提供了对容器的交互式shell访问:
这里我们选用ubuntu镜像,为什么使用ubentu镜像呢?
[root@docker ~]# docker images REPOSITORY TAG IMAGE ID CREATED SIZE circledba/kingbase v008r006c007b0024 df101ff5974d 40 hours ago 12.4GB tomcat latest fb5657adc892 23 months ago 680MB ubuntu latest ba6acccedd29 2 years ago 72.8MB centos 7 eeb6ee3f44bd 2 years ago 204MB [root@docker ~]#
centos7镜像大小为204MB,ubuntu只有72.8MB
现在已经进入docker内部,在这个环境下,shell展现如下:
[root@docker ~]# docker run -it ubuntu
root@12adcd8f7dd9:/#
注意:ubuntu镜像是最小化的基本上没有什么常用的用具,比如说ip命令等,演示如下
root@12adcd8f7dd9:/# ip
bash: ip: command not found
root@12adcd8f7dd9:/# yum
bash: yum: command not found
root@12adcd8f7dd9:/#
那就需要我们手动安装
- 我们先更新apt工具(不更新会找不到很多包)
apt-get update
apt-get upgrade
运行示例:
root@12adcd8f7dd9:/# apt-get update
Get:1 http://archive.ubuntu.com/ubuntu focal InRelease [265 kB]
Get:2 http://security.ubuntu.com/ubuntu focal-security InRelease [114 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates InRelease [114 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-backports InRelease [108 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal/multiverse amd64 Packages [177 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal/restricted amd64 Packages [33.4 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 Packages [1275 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/universe amd64 Packages [11.3 MB]
Get:9 http://security.ubuntu.com/ubuntu focal-security/main amd64 Packages [3245 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/universe amd64 Packages [1443 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/restricted amd64 Packages [3272 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/multiverse amd64 Packages [32.0 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 Packages [3754 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-backports/main amd64 Packages [55.2 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-backports/universe amd64 Packages [28.6 kB]
Get:16 http://security.ubuntu.com/ubuntu focal-security/universe amd64 Packages [1148 kB]
Get:17 http://security.ubuntu.com/ubuntu focal-security/multiverse amd64 Packages [29.3 kB]
Get:18 http://security.ubuntu.com/ubuntu focal-security/restricted amd64 Packages [3079 kB]
Fetched 29.5 MB in 50s (596 kB/s)
Reading package lists... Done
root@12adcd8f7dd9:/# apt-get upgrade
Reading package lists... Done
Building dependency tree
Reading state information... Done
Calculating upgrade... Done
The following packages will be upgraded:
apt base-files bash bsdutils dpkg e2fsprogs fdisk gcc-10-base gpgv gzip libapt-pkg6.0 libblkid1 libc-bin
libc6 libcom-err2 libext2fs2 libfdisk1 libgcc-s1 libgmp10 libgnutls30 liblzma5 libmount1 libncurses6
libncursesw6 libpam-modules libpam-modules-bin libpam-runtime libpam0g libpcre2-8-0 libpcre3 libprocps8
libseccomp2 libsepol1 libsmartcols1 libss2 libstdc++6 libsystemd0 libtinfo6 libudev1 libuuid1 login
logsave mount ncurses-base ncurses-bin passwd perl-base procps tar util-linux zlib1g
51 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
Need to get 17.0 MB of archives.
After this operation, 39.9 kB of additional disk space will be used.
Do you want to continue? [Y/n] y
Get:1 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gcc-10-base amd64 10.5.0-1ubuntu1~20.04 [20.8 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libgcc-s1 amd64 10.5.0-1ubuntu1~20.04 [41.8 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libstdc++6 amd64 10.5.0-1ubuntu1~20.04 [501 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc6 amd64 2.31-0ubuntu9.14 [2725 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 base-files amd64 11ubuntu5.7 [60.4 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 bash amd64 5.0-6ubuntu1.2 [639 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 bsdutils amd64 1:2.34-0.1ubuntu9.4 [63.0 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 tar amd64 1.30+dfsg-7ubuntu0.20.04.3 [240 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 dpkg amd64 1.19.7ubuntu3.2 [1128 kB]
Get:10 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gzip amd64 1.10-0ubuntu4.1 [95.2 kB]
Get:11 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 login amd64 1:4.8.1-1ubuntu5.20.04.4 [221 kB]
Get:12 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 ncurses-bin amd64 6.2-0ubuntu2.1 [172 kB]
Get:13 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 perl-base amd64 5.30.0-9ubuntu0.5 [1514 kB]
Get:14 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libblkid1 amd64 2.34-0.1ubuntu9.4 [137 kB]
Get:15 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libuuid1 amd64 2.34-0.1ubuntu9.4 [20.0 kB]
Get:16 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libfdisk1 amd64 2.34-0.1ubuntu9.4 [174 kB]
Get:17 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libmount1 amd64 2.34-0.1ubuntu9.4 [150 kB]
Get:18 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libncurses6 amd64 6.2-0ubuntu2.1 [101 kB]
Get:19 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libncursesw6 amd64 6.2-0ubuntu2.1 [132 kB]
Get:20 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libtinfo6 amd64 6.2-0ubuntu2.1 [87.4 kB]
Get:21 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsmartcols1 amd64 2.34-0.1ubuntu9.4 [100 kB]
Get:22 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 fdisk amd64 2.34-0.1ubuntu9.4 [119 kB]
Get:23 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 util-linux amd64 2.34-0.1ubuntu9.4 [1021 kB]
Get:24 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libc-bin amd64 2.31-0ubuntu9.14 [635 kB]
Get:25 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 ncurses-base all 6.2-0ubuntu2.1 [18.9 kB]
Get:26 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 liblzma5 amd64 5.2.4-1ubuntu1.1 [91.8 kB]
Get:27 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsystemd0 amd64 245.4-4ubuntu3.22 [267 kB]
Get:28 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libudev1 amd64 245.4-4ubuntu3.22 [75.4 kB]
Get:29 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 zlib1g amd64 1:1.2.11.dfsg-2ubuntu1.5 [54.2 kB]
Get:30 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libapt-pkg6.0 amd64 2.0.10 [843 kB]
Get:31 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 gpgv amd64 2.2.19-3ubuntu2.2 [200 kB]
Get:32 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libgmp10 amd64 2:6.2.0+dfsg-4ubuntu0.1 [241 kB]
Get:33 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libgnutls30 amd64 3.6.13-2ubuntu1.9 [828 kB]
Get:34 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libseccomp2 amd64 2.5.1-1ubuntu1~20.04.2 [42.5 kB]
Get:35 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 apt amd64 2.0.10 [1280 kB]
Get:36 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpam0g amd64 1.3.1-5ubuntu4.6 [55.3 kB]
Get:37 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpam-modules-bin amd64 1.3.1-5ubuntu4.6 [41.2 kB]
Get:38 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpam-modules amd64 1.3.1-5ubuntu4.6 [260 kB]
Get:39 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 logsave amd64 1.45.5-2ubuntu1.1 [10.2 kB]
Get:40 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libext2fs2 amd64 1.45.5-2ubuntu1.1 [183 kB]
Get:41 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 e2fsprogs amd64 1.45.5-2ubuntu1.1 [527 kB]
Get:42 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 mount amd64 2.34-0.1ubuntu9.4 [115 kB]
Get:43 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpam-runtime all 1.3.1-5ubuntu4.6 [37.3 kB]
Get:44 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpcre2-8-0 amd64 10.34-7ubuntu0.1 [198 kB]
Get:45 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpcre3 amd64 2:8.39-12ubuntu0.1 [232 kB]
Get:46 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libsepol1 amd64 3.0-1ubuntu0.1 [252 kB]
Get:47 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 passwd amd64 1:4.8.1-1ubuntu5.20.04.4 [799 kB]
Get:48 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcom-err2 amd64 1.45.5-2ubuntu1.1 [9548 B]
Get:49 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libprocps8 amd64 2:3.3.16-1ubuntu2.4 [33.1 kB]
Get:50 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libss2 amd64 1.45.5-2ubuntu1.1 [11.3 kB]
Get:51 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 procps amd64 2:3.3.16-1ubuntu2.4 [232 kB]
Fetched 17.0 MB in 1min 3s (270 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../gcc-10-base_10.5.0-1ubuntu1~20.04_amd64.deb ...
Unpacking gcc-10-base:amd64 (10.5.0-1ubuntu1~20.04) over (10.3.0-1ubuntu1~20.04) ...
Setting up gcc-10-base:amd64 (10.5.0-1ubuntu1~20.04) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libgcc-s1_10.5.0-1ubuntu1~20.04_amd64.deb ...
Unpacking libgcc-s1:amd64 (10.5.0-1ubuntu1~20.04) over (10.3.0-1ubuntu1~20.04) ...
Setting up libgcc-s1:amd64 (10.5.0-1ubuntu1~20.04) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libstdc++6_10.5.0-1ubuntu1~20.04_amd64.deb ...
Unpacking libstdc++6:amd64 (10.5.0-1ubuntu1~20.04) over (10.3.0-1ubuntu1~20.04) ...
Setting up libstdc++6:amd64 (10.5.0-1ubuntu1~20.04) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libc6_2.31-0ubuntu9.14_amd64.deb ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Unpacking libc6:amd64 (2.31-0ubuntu9.14) over (2.31-0ubuntu9.2) ...
Setting up libc6:amd64 (2.31-0ubuntu9.14) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../base-files_11ubuntu5.7_amd64.deb ...
Unpacking base-files (11ubuntu5.7) over (11ubuntu5.4) ...
Setting up base-files (11ubuntu5.7) ...
Installing new version of config file /etc/issue ...
Installing new version of config file /etc/issue.net ...
Installing new version of config file /etc/lsb-release ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../bash_5.0-6ubuntu1.2_amd64.deb ...
Unpacking bash (5.0-6ubuntu1.2) over (5.0-6ubuntu1.1) ...
Setting up bash (5.0-6ubuntu1.2) ...
update-alternatives: error: alternative path /usr/share/man/man7/bash-builtins.7.gz doesn't exist
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../bsdutils_1%3a2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking bsdutils (1:2.34-0.1ubuntu9.4) over (1:2.34-0.1ubuntu9.1) ...
Setting up bsdutils (1:2.34-0.1ubuntu9.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../tar_1.30+dfsg-7ubuntu0.20.04.3_amd64.deb ...
Unpacking tar (1.30+dfsg-7ubuntu0.20.04.3) over (1.30+dfsg-7ubuntu0.20.04.1) ...
Setting up tar (1.30+dfsg-7ubuntu0.20.04.3) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../dpkg_1.19.7ubuntu3.2_amd64.deb ...
Unpacking dpkg (1.19.7ubuntu3.2) over (1.19.7ubuntu3) ...
Setting up dpkg (1.19.7ubuntu3.2) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../gzip_1.10-0ubuntu4.1_amd64.deb ...
Unpacking gzip (1.10-0ubuntu4.1) over (1.10-0ubuntu4) ...
Setting up gzip (1.10-0ubuntu4.1) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../login_1%3a4.8.1-1ubuntu5.20.04.4_amd64.deb ...
Unpacking login (1:4.8.1-1ubuntu5.20.04.4) over (1:4.8.1-1ubuntu5.20.04.1) ...
Setting up login (1:4.8.1-1ubuntu5.20.04.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../ncurses-bin_6.2-0ubuntu2.1_amd64.deb ...
Unpacking ncurses-bin (6.2-0ubuntu2.1) over (6.2-0ubuntu2) ...
Setting up ncurses-bin (6.2-0ubuntu2.1) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../perl-base_5.30.0-9ubuntu0.5_amd64.deb ...
Unpacking perl-base (5.30.0-9ubuntu0.5) over (5.30.0-9ubuntu0.2) ...
Setting up perl-base (5.30.0-9ubuntu0.5) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libblkid1_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking libblkid1:amd64 (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Setting up libblkid1:amd64 (2.34-0.1ubuntu9.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libuuid1_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking libuuid1:amd64 (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Setting up libuuid1:amd64 (2.34-0.1ubuntu9.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libfdisk1_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking libfdisk1:amd64 (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Preparing to unpack .../libmount1_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking libmount1:amd64 (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Setting up libmount1:amd64 (2.34-0.1ubuntu9.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libncurses6_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libncurses6:amd64 (6.2-0ubuntu2.1) over (6.2-0ubuntu2) ...
Preparing to unpack .../libncursesw6_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libncursesw6:amd64 (6.2-0ubuntu2.1) over (6.2-0ubuntu2) ...
Preparing to unpack .../libtinfo6_6.2-0ubuntu2.1_amd64.deb ...
Unpacking libtinfo6:amd64 (6.2-0ubuntu2.1) over (6.2-0ubuntu2) ...
Setting up libtinfo6:amd64 (6.2-0ubuntu2.1) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libsmartcols1_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking libsmartcols1:amd64 (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Setting up libsmartcols1:amd64 (2.34-0.1ubuntu9.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../fdisk_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking fdisk (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Preparing to unpack .../util-linux_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking util-linux (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Setting up util-linux (2.34-0.1ubuntu9.4) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libc-bin_2.31-0ubuntu9.14_amd64.deb ...
Unpacking libc-bin (2.31-0ubuntu9.14) over (2.31-0ubuntu9.2) ...
Setting up libc-bin (2.31-0ubuntu9.14) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../ncurses-base_6.2-0ubuntu2.1_all.deb ...
Unpacking ncurses-base (6.2-0ubuntu2.1) over (6.2-0ubuntu2) ...
Setting up ncurses-base (6.2-0ubuntu2.1) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../liblzma5_5.2.4-1ubuntu1.1_amd64.deb ...
Unpacking liblzma5:amd64 (5.2.4-1ubuntu1.1) over (5.2.4-1ubuntu1) ...
Setting up liblzma5:amd64 (5.2.4-1ubuntu1.1) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libsystemd0_245.4-4ubuntu3.22_amd64.deb ...
Unpacking libsystemd0:amd64 (245.4-4ubuntu3.22) over (245.4-4ubuntu3.13) ...
Setting up libsystemd0:amd64 (245.4-4ubuntu3.22) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libudev1_245.4-4ubuntu3.22_amd64.deb ...
Unpacking libudev1:amd64 (245.4-4ubuntu3.22) over (245.4-4ubuntu3.13) ...
Setting up libudev1:amd64 (245.4-4ubuntu3.22) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../zlib1g_1%3a1.2.11.dfsg-2ubuntu1.5_amd64.deb ...
Unpacking zlib1g:amd64 (1:1.2.11.dfsg-2ubuntu1.5) over (1:1.2.11.dfsg-2ubuntu1.2) ...
Setting up zlib1g:amd64 (1:1.2.11.dfsg-2ubuntu1.5) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libapt-pkg6.0_2.0.10_amd64.deb ...
Unpacking libapt-pkg6.0:amd64 (2.0.10) over (2.0.6) ...
Setting up libapt-pkg6.0:amd64 (2.0.10) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../gpgv_2.2.19-3ubuntu2.2_amd64.deb ...
Unpacking gpgv (2.2.19-3ubuntu2.2) over (2.2.19-3ubuntu2.1) ...
Setting up gpgv (2.2.19-3ubuntu2.2) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libgmp10_2%3a6.2.0+dfsg-4ubuntu0.1_amd64.deb ...
Unpacking libgmp10:amd64 (2:6.2.0+dfsg-4ubuntu0.1) over (2:6.2.0+dfsg-4) ...
Setting up libgmp10:amd64 (2:6.2.0+dfsg-4ubuntu0.1) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libgnutls30_3.6.13-2ubuntu1.9_amd64.deb ...
Unpacking libgnutls30:amd64 (3.6.13-2ubuntu1.9) over (3.6.13-2ubuntu1.6) ...
Setting up libgnutls30:amd64 (3.6.13-2ubuntu1.9) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../libseccomp2_2.5.1-1ubuntu1~20.04.2_amd64.deb ...
Unpacking libseccomp2:amd64 (2.5.1-1ubuntu1~20.04.2) over (2.5.1-1ubuntu1~20.04.1) ...
Setting up libseccomp2:amd64 (2.5.1-1ubuntu1~20.04.2) ...
(Reading database ... 4345 files and directories currently installed.)
Preparing to unpack .../archives/apt_2.0.10_amd64.deb ...
Unpacking apt (2.0.10) over (2.0.6) ...
Setting up apt (2.0.10) ...
Removing obsolete conffile /etc/kernel/postinst.d/apt-auto-removal ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libpam0g_1.3.1-5ubuntu4.6_amd64.deb ...
Unpacking libpam0g:amd64 (1.3.1-5ubuntu4.6) over (1.3.1-5ubuntu4.3) ...
Setting up libpam0g:amd64 (1.3.1-5ubuntu4.6) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libpam-modules-bin_1.3.1-5ubuntu4.6_amd64.deb ...
Unpacking libpam-modules-bin (1.3.1-5ubuntu4.6) over (1.3.1-5ubuntu4.3) ...
Setting up libpam-modules-bin (1.3.1-5ubuntu4.6) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libpam-modules_1.3.1-5ubuntu4.6_amd64.deb ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Unpacking libpam-modules:amd64 (1.3.1-5ubuntu4.6) over (1.3.1-5ubuntu4.3) ...
Setting up libpam-modules:amd64 (1.3.1-5ubuntu4.6) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../logsave_1.45.5-2ubuntu1.1_amd64.deb ...
Unpacking logsave (1.45.5-2ubuntu1.1) over (1.45.5-2ubuntu1) ...
Preparing to unpack .../libext2fs2_1.45.5-2ubuntu1.1_amd64.deb ...
Unpacking libext2fs2:amd64 (1.45.5-2ubuntu1.1) over (1.45.5-2ubuntu1) ...
Setting up libext2fs2:amd64 (1.45.5-2ubuntu1.1) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../e2fsprogs_1.45.5-2ubuntu1.1_amd64.deb ...
Unpacking e2fsprogs (1.45.5-2ubuntu1.1) over (1.45.5-2ubuntu1) ...
Preparing to unpack .../mount_2.34-0.1ubuntu9.4_amd64.deb ...
Unpacking mount (2.34-0.1ubuntu9.4) over (2.34-0.1ubuntu9.1) ...
Preparing to unpack .../libpam-runtime_1.3.1-5ubuntu4.6_all.deb ...
Unpacking libpam-runtime (1.3.1-5ubuntu4.6) over (1.3.1-5ubuntu4.3) ...
Setting up libpam-runtime (1.3.1-5ubuntu4.6) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libpcre2-8-0_10.34-7ubuntu0.1_amd64.deb ...
Unpacking libpcre2-8-0:amd64 (10.34-7ubuntu0.1) over (10.34-7) ...
Setting up libpcre2-8-0:amd64 (10.34-7ubuntu0.1) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libpcre3_2%3a8.39-12ubuntu0.1_amd64.deb ...
Unpacking libpcre3:amd64 (2:8.39-12ubuntu0.1) over (2:8.39-12build1) ...
Setting up libpcre3:amd64 (2:8.39-12ubuntu0.1) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libsepol1_3.0-1ubuntu0.1_amd64.deb ...
Unpacking libsepol1:amd64 (3.0-1ubuntu0.1) over (3.0-1) ...
Setting up libsepol1:amd64 (3.0-1ubuntu0.1) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../passwd_1%3a4.8.1-1ubuntu5.20.04.4_amd64.deb ...
Unpacking passwd (1:4.8.1-1ubuntu5.20.04.4) over (1:4.8.1-1ubuntu5.20.04.1) ...
Setting up passwd (1:4.8.1-1ubuntu5.20.04.4) ...
(Reading database ... 4342 files and directories currently installed.)
Preparing to unpack .../libcom-err2_1.45.5-2ubuntu1.1_amd64.deb ...
Unpacking libcom-err2:amd64 (1.45.5-2ubuntu1.1) over (1.45.5-2ubuntu1) ...
Preparing to unpack .../libprocps8_2%3a3.3.16-1ubuntu2.4_amd64.deb ...
Unpacking libprocps8:amd64 (2:3.3.16-1ubuntu2.4) over (2:3.3.16-1ubuntu2.3) ...
Preparing to unpack .../libss2_1.45.5-2ubuntu1.1_amd64.deb ...
Unpacking libss2:amd64 (1.45.5-2ubuntu1.1) over (1.45.5-2ubuntu1) ...
Preparing to unpack .../procps_2%3a3.3.16-1ubuntu2.4_amd64.deb ...
Unpacking procps (2:3.3.16-1ubuntu2.4) over (2:3.3.16-1ubuntu2.3) ...
Setting up libcom-err2:amd64 (1.45.5-2ubuntu1.1) ...
Setting up libncurses6:amd64 (6.2-0ubuntu2.1) ...
Setting up libss2:amd64 (1.45.5-2ubuntu1.1) ...
Setting up libncursesw6:amd64 (6.2-0ubuntu2.1) ...
Setting up logsave (1.45.5-2ubuntu1.1) ...
Setting up libfdisk1:amd64 (2.34-0.1ubuntu9.4) ...
Setting up mount (2.34-0.1ubuntu9.4) ...
Setting up libprocps8:amd64 (2:3.3.16-1ubuntu2.4) ...
Setting up e2fsprogs (1.45.5-2ubuntu1.1) ...
Setting up fdisk (2.34-0.1ubuntu9.4) ...
Setting up procps (2:3.3.16-1ubuntu2.4) ...
Processing triggers for libc-bin (2.31-0ubuntu9.14) ...
root@12adcd8f7dd9:/#
- 安装IP工具包
root@12adcd8f7dd9:/# apt install -y iproute2
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libatm1 libbsd0 libcap2 libcap2-bin libelf1 libmnl0 libpam-cap libxtables12
Suggested packages:
iproute2-doc
The following NEW packages will be installed:
iproute2 libatm1 libbsd0 libcap2 libcap2-bin libelf1 libmnl0 libpam-cap libxtables12
0 upgraded, 9 newly installed, 0 to remove and 51 not upgraded.
Need to get 1061 kB of archives.
After this operation, 3682 kB of additional disk space will be used.
Get:1 http://archive.ubuntu.com/ubuntu focal/main amd64 libbsd0 amd64 0.10.0-1 [45.4 kB]
Get:2 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcap2 amd64 1:2.32-1ubuntu0.1 [15.8 kB]
Get:3 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libelf1 amd64 0.176-1.1ubuntu0.1 [44.2 kB]
Get:4 http://archive.ubuntu.com/ubuntu focal/main amd64 libmnl0 amd64 1.0.4-2 [12.3 kB]
Get:5 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libxtables12 amd64 1.8.4-3ubuntu2.1 [28.7 kB]
Get:6 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libcap2-bin amd64 1:2.32-1ubuntu0.1 [26.2 kB]
Get:7 http://archive.ubuntu.com/ubuntu focal/main amd64 iproute2 amd64 5.5.0-1ubuntu1 [858 kB]
Get:8 http://archive.ubuntu.com/ubuntu focal/main amd64 libatm1 amd64 1:2.5.1-4 [21.8 kB]
Get:9 http://archive.ubuntu.com/ubuntu focal-updates/main amd64 libpam-cap amd64 1:2.32-1ubuntu0.1 [8364 B]
Fetched 1061 kB in 6s (177 kB/s)
debconf: delaying package configuration, since apt-utils is not installed
Selecting previously unselected package libbsd0:amd64.
(Reading database ... 4127 files and directories currently installed.)
Preparing to unpack .../0-libbsd0_0.10.0-1_amd64.deb ...
Unpacking libbsd0:amd64 (0.10.0-1) ...
Selecting previously unselected package libcap2:amd64.
Preparing to unpack .../1-libcap2_1%3a2.32-1ubuntu0.1_amd64.deb ...
Unpacking libcap2:amd64 (1:2.32-1ubuntu0.1) ...
Selecting previously unselected package libelf1:amd64.
Preparing to unpack .../2-libelf1_0.176-1.1ubuntu0.1_amd64.deb ...
Unpacking libelf1:amd64 (0.176-1.1ubuntu0.1) ...
Selecting previously unselected package libmnl0:amd64.
Preparing to unpack .../3-libmnl0_1.0.4-2_amd64.deb ...
Unpacking libmnl0:amd64 (1.0.4-2) ...
Selecting previously unselected package libxtables12:amd64.
Preparing to unpack .../4-libxtables12_1.8.4-3ubuntu2.1_amd64.deb ...
Unpacking libxtables12:amd64 (1.8.4-3ubuntu2.1) ...
Selecting previously unselected package libcap2-bin.
Preparing to unpack .../5-libcap2-bin_1%3a2.32-1ubuntu0.1_amd64.deb ...
Unpacking libcap2-bin (1:2.32-1ubuntu0.1) ...
Selecting previously unselected package iproute2.
Preparing to unpack .../6-iproute2_5.5.0-1ubuntu1_amd64.deb ...
Unpacking iproute2 (5.5.0-1ubuntu1) ...
Selecting previously unselected package libatm1:amd64.
Preparing to unpack .../7-libatm1_1%3a2.5.1-4_amd64.deb ...
Unpacking libatm1:amd64 (1:2.5.1-4) ...
Selecting previously unselected package libpam-cap:amd64.
Preparing to unpack .../8-libpam-cap_1%3a2.32-1ubuntu0.1_amd64.deb ...
Unpacking libpam-cap:amd64 (1:2.32-1ubuntu0.1) ...
Setting up libatm1:amd64 (1:2.5.1-4) ...
Setting up libcap2:amd64 (1:2.32-1ubuntu0.1) ...
Setting up libcap2-bin (1:2.32-1ubuntu0.1) ...
Setting up libmnl0:amd64 (1.0.4-2) ...
Setting up libxtables12:amd64 (1.8.4-3ubuntu2.1) ...
Setting up libbsd0:amd64 (0.10.0-1) ...
Setting up libelf1:amd64 (0.176-1.1ubuntu0.1) ...
Setting up libpam-cap:amd64 (1:2.32-1ubuntu0.1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Setting up iproute2 (5.5.0-1ubuntu1) ...
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
debconf: unable to initialize frontend: Readline
debconf: (Can't locate Term/ReadLine.pm in @INC (you may need to install the Term::ReadLine module) (@INC contains: /etc/perl /usr/local/lib/x86_64-linux-gnu/perl/5.30.0 /usr/local/share/perl/5.30.0 /usr/lib/x86_64-linux-gnu/perl5/5.30 /usr/share/perl5 /usr/lib/x86_64-linux-gnu/perl/5.30 /usr/share/perl/5.30 /usr/local/lib/site_perl /usr/lib/x86_64-linux-gnu/perl-base) at /usr/share/perl5/Debconf/FrontEnd/Readline.pm line 7.)
debconf: falling back to frontend: Teletype
Processing triggers for libc-bin (2.31-0ubuntu9.2) ...
root@12adcd8f7dd9:/# ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
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
6: eth0@if7: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default
link/ether 02:42:ac:11:00:02 brd ff:ff:ff:ff:ff:ff link-netnsid 0
inet 172.17.0.2/16 brd 172.17.255.255 scope global eth0
valid_lft forever preferred_lft forever
root@12adcd8f7dd9:/#
我们的ip命令就可以正常使用了
终止容器
[root@docker ~]# docker ps -all #现在是启动中的容器状态Up 6 seconds
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
12adcd8f7dd9 ubuntu "bash" 19 minutes ago Up 6 seconds optimistic_jackson
[root@docker ~]# docker stop 12adcd8f7dd9 #现在是停止容器
12adcd8f7dd9
[root@docker ~]# docker ps -all #现在是停止容器 Exited (0) 2 seconds ago
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
12adcd8f7dd9 ubuntu "bash" 20 minutes ago Exited (0) 2 seconds ago optimistic_jackson
[root@docker ~]#
进入容器
使用-d参数运行容器时,容器启动后会进入后台。此时想要进入容器,可以通过以下指令进入:
● docker attach:使用这个命令进入容器,退出时会导致容器停止。
● docker exec:推荐大家使用docker exec命令,因为此命令会退出容器终端,但不会导致容器的停止。
docker attach
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3deae30b2ec7 ubuntu "bash" 5 seconds ago Up 4 seconds hungry_merkle
[root@docker ~]# docker attach 3deae30b2ec7
root@3deae30b2ec7:/# exit
exit
[root@docker ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3deae30b2ec7 ubuntu "bash" 4 minutes ago Exited (0) 37 seconds ago hungry_merkle
12adcd8f7dd9 ubuntu "bash" 27 minutes ago Exited (0) 7 minutes ago optimistic_jackson
我们发现容器会停止,我们再次启动容器使用 crtl+p+q 退出
[root@docker ~]# docker start 3deae30b2ec7
3deae30b2ec7
[root@docker ~]# docker attach 3deae30b2ec7
root@3deae30b2ec7:/# read escape sequence
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3deae30b2ec7 ubuntu "bash" 6 minutes ago Up 26 seconds hungry_merkle
12adcd8f7dd9 ubuntu "bash" 28 minutes ago Exited (0) 8 minutes ago optimistic_jackson
[root@docker ~]#
容器是正常运行的
docker exec
[root@docker ~]# docker exec -it 3deae30b2ec7 /bin/bash
root@3deae30b2ec7:/# exit
exit
[root@docker ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
3deae30b2ec7 ubuntu "bash" 23 minutes ago Up 18 minutes hungry_merkle
12adcd8f7dd9 ubuntu "bash" 46 minutes ago Exited (0) 26 minutes ago optimistic_jackson
[root@docker ~]#
注意: 使用docker exec进入容器,如果从这个容器退出,容器不会停止,因此推荐使用docker exec。
导出和导入
导出
如果要导出本地某个容器,可以使用 docker export 命令。为以后我们不需要重复安装ip命令做准备
例如,导出容器 3deae30b2ec7快照到本地文件 ubuntu.tar:
[root@docker ~]# docker export 3deae30b2ec7 > ubuntu.tar
[root@docker ~]# ls -l
总用量 73404
-rw-------. 1 root root 1323 11月 21 15:44 anaconda-ks.cfg
-rw-r--r--. 1 root root 75158528 12月 9 11:20 ubuntu.tar
[root@docker ~]#
导入
可以使用 docker import 从本地容器快照文件中再导入为镜像,以下实例将快照文件 ubuntu.tar 导入到镜像 test/ubuntu:v1:
[root@docker ~]# docker import ubuntu.tar circle/ubuntu:1.0
sha256:34035f46d2c6227f66338127ef939b7757b115f4d2a485fc06f84971604da062
[root@docker ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
circle/ubuntu 1.0 34035f46d2c6 6 seconds ago 72.8MB
circledba/kingbase v008r006c007b0024 df101ff5974d 41 hours ago 12.4GB
tomcat latest fb5657adc892 23 months ago 680MB
ubuntu latest ba6acccedd29 2 years ago 72.8MB
centos 7 eeb6ee3f44bd 2 years ago 204MB
[root@docker ~]#
还可以通过指定 URL 或者某个目录来导入,例如:
docker import http://example.com/exampleimage.tgz example/imagerepo
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。 如若内容造成侵权/违法违规/事实不符,请联系我的编程经验分享网邮箱:veading@qq.com进行投诉反馈,一经查实,立即删除!