查看docker是否正常工作:
docker info
Containers: 19 Running: 14 Paused: 0 Stopped: 5 Images: 24 Server Version: 1.13.1 Storage Driver: overlay2 Backing Filesystem: xfs Supports d_type: true Native Overlay Diff: false Logging Driver: journald Cgroup Driver: systemd Plugins: Volume: local Network: bridge host macvlan null overlay Swarm: inactive Runtimes: docker-runc runc Default Runtime: docker-runc Init Binary: /usr/libexec/docker/docker-init-current containerd version: (expected: aa8187dbd3b7ad67d8e5e3a15115d3eef43a7ed1) runc version: 66aedde759f33c190954815fb765eedc1d782dd9 (expected: 9df8b306d01f59d3a8029be411de015b7304dd8f) init version: fec3683b971d9c3ef73f284f176672c44b448662 (expected: 949e6facb77383876aeff8a6944dde66b3089574) Security Options: seccomp WARNING: You're not using the default seccomp profile Profile: /etc/docker/seccomp.json Kernel Version: 3.10.0-514.el7.x86_64 Operating System: CentOS Linux 7 (Core) OSType: linux Architecture: x86_64 Number of Docker Hooks: 3 CPUs: 2 Total Memory: 7.64 GiB Name: JD ID: RTW4:WSG7:7PSL:KSO7:ENOZ:MQ44:2ZYQ:7OI4:FIDZ:ZWVP:JTYE:NM67 Docker Root Dir: /var/lib/docker Debug Mode (client): false Debug Mode (server): false Registry: https://index.docker.io/v1/ WARNING: bridge-nf-call-ip6tables is disabled Experimental: false Insecure Registries: 114.67.90.75:5000 127.0.0.0/8 Live Restore Enabled: false Registries: docker.io (secure)
docker run -d -it --name jmeter5.2.1 -v $PWD/test:/test jmeter
docker run 命令,指定了-i和-t两个命令行参数,-i标志容器中的stdin是开启的,虽然我么目前还没有进入容器中;-t表明分配一个伪中断,-d表明后台运行容器,并返回容器ID;
查看日志:
docker logs 7e7bf911a3a0
查看镜像:docker images
如何查看运行的容器id呢?
docker ps
查看已经创建的容器:
docker ps -a
进入docker容器内部,指定你要进入的id
docker exec -it 7e7bf911a3a0 /bin/bash
容器的主机名就是容器的id
[root@JD ~]# docker exec -it 7e7bf911a3a0 /bin/bash root@7e7bf911a3a0:/# hostname 7e7bf911a3a0 root@7e7bf911a3a0:/#
查看容器的hosts
root@7e7bf911a3a0:/# cat /etc/hosts 127.0.0.1 localhost ::1 localhost ip6-localhost ip6-loopback fe00::0 ip6-localnet ff00::0 ip6-mcastprefix ff02::1 ip6-allnodes ff02::2 ip6-allrouters 172.17.0.4 7e7bf911a3a0
网卡信息
root@7e7bf911a3a0:/# ip a 1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1 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 44: eth0@if45: <BROADCAST,MULTICAST,UP,LOWER_UP> mtu 1500 qdisc noqueue state UP group default link/ether 02:42:ac:11:00:04 brd ff:ff:ff:ff:ff:ff inet 172.17.0.4/16 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::42:acff:fe11:4/64 scope link valid_lft forever preferred_lft forever
退出容器
exit