docker 端口映射

docker 删除所有容器   必须先停再删,再启动
[root@localhost ~]#
[root@localhost ~]# docker rm $(docker ps -qa)
1f2abcd6ae16
Error response from daemon: cannot remove container "/c1": container is running: stop the container before removing or force remove
Error response from daemon: cannot remove container "/c7": container is running: stop the container before removing or force remove
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker stop c1
c1
[root@localhost ~]# docker stop c7
c7
[root@localhost ~]# docker rm $(docker ps -qa)
a2e58a56047d
e40e729d2da2
[root@localhost ~]#
[root@localhost ~]#

[root@localhost ~]#
[root@localhost ~]# docker run --name nginx -d nginx:latest
68b6d46d483fd0094c0e3c6fae62ab31a35576b042079fadc666bb8b6f95d913
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
68b6d46d483f   nginx:latest   "/docker-entrypoint.…"   6 seconds ago   Up 5 seconds   80/tcp    nginx
[root@localhost ~]#
[root@localhost ~]#
启动nginx容器
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
68b6d46d483f   nginx:latest   "/docker-entrypoint.…"   6 seconds ago   Up 5 seconds   80/tcp    nginx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker stop nginx
nginx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker rm nginx
nginx
[root@localhost ~]#
删除nginx做端口印射
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS     NAMES
68b6d46d483f   nginx:latest   "/docker-entrypoint.…"   6 seconds ago   Up 5 seconds   80/tcp    nginx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker stop nginx
nginx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker rm nginx
nginx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker run --name nginx -p 80:80 -d nginx:latest
a4fa9d11f864bfe15fc6e4c06aa441ed2390044d2b4a3cc958aaf70881aa9a40
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# docker ps
CONTAINER ID   IMAGE          COMMAND                  CREATED         STATUS         PORTS                               NAMES
a4fa9d11f864   nginx:latest   "/docker-entrypoint.…"   7 seconds ago   Up 6 seconds   0.0.0.0:80->80/tcp, :::80->80/tcp   nginx
[root@localhost ~]#
[root@localhost ~]#
[root@localhost ~]# vim 1.sh
[root@localhost ~]#
[root@localhost ~]# sh 1.sh
Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
=== firewalld已关闭并禁用 ===
=== SELinux已临时关闭,且配置为永久禁用 ===
Removed symlink /etc/systemd/system/multi-user.target.wants/NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.NetworkManager.service.
Removed symlink /etc/systemd/system/dbus-org.freedesktop.nm-dispatcher.service.
Removed symlink /etc/systemd/system/network-online.target.wants/NetworkManager-wait-online.service.
=== NetworkManager已关闭并禁用 ===
所有安全组件已按要求关闭完成!
[root@localhost ~]#
[root@localhost ~]#


真实机80端口映射
