Docker native network(What,How,Why)
None
Description: Disable network
  1. How to use none network?
[root@localhost ~]# docker run --rm \
-dit --network none \
--name no-net-alpine \
alpine:latest \
ash
Explanation: run a command in a new container
parameters:
--rm: when the container exited, delete the container.
-d: run in dettach mode, run the container in background.
-i: keep STDIN open even it is not attached.
-t: Allocate a pseudo-TTY
--name: assign a name to the container
Chcker Images:
REPOSITORY TAG IMAGE ID CREATED SIZE
alpine latest 3fd9065eaf02 2 months ago 4.14MB
Check Container:
[root@localhost ~]# docker container ls
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c199c40cac34 alpine:latest "ash" 15 minutes ago Up 15 minutes no-net-alpine
Check the network settings
docker inspect c199c40cac34
"Networks": {
"none": {
"IPAMConfig": null,
"Links": null,
"Aliases": null,
"NetworkID": "f80e6afec2c4e555bc11974ca3996780b8caaf00eed2551b4a89e0a461491d09",
"EndpointID": "16613fd17a4675b0bbe4042d6f27ca052d4b233e3c506cb3a454852b5a8921fc",
"Gateway": "",
"IPAddress": "",
"IPPrefixLen": 0,
"IPv6Gateway": "",
"GlobalIPv6Address": "",
"GlobalIPv6PrefixLen": 0,
"MacAddress": "",
"DriverOpts": null
}
Check the link status in container
[root@localhost ~]# docker exec no-net-alpine ip link show
1: lo: mtu 65536 qdisc noqueue state UNKNOWN qlen 1
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
Check the route in container
[root@localhost ~]# docker exec no-net-alpine ip route
#it will show nothing, no route info for this container.
2. Usage of None network
Some application with analysis data, generate report and other batch tasks.
10-07 15:44