Networking (15%) Flashcards

Networking (15%)

1
Q

What is the default network that the docker creates automatically?

A

Bridge

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How to list the networks on the Docker machine?

A

docker netwrok ls

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How to connect to the default bridge network when you create a container?

A

// since no network is specified, it will be connected to default bridge network

docker run -dit –name alpine1 alpine ash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

How to inspect the default network bridge?

A

docker network inspect bridge

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

The default bridge network is not recommended for production. Is this statement correct?

A

Yes

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to create a user-defined network?

A

docker network create –driver bridge my-network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

How to inspect the user-defined network?

A

docker network inspect my-network

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

How to connect to the user-defined network while creating a container?

A

docker run -dit –name alpine1 –network my-network alpine ash

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

How to connect the existing container to the user-defined network?

A

docker netwrok connect my-network alpine2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How to troubleshoot a user-defined network?

A
// using  nicolaka/netshootdocker 
run -it --rm --network container: nicolaka/netshoot
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

How to publish a port so that it can be accessed externally?

A

docker run -p 127.0.0.1:$HOSTPORT:$CONTAINERPORT –name CONTAINER -t

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

How to list port mappings or a specific mapping for the container?

A
// List the containers
docker ps
// use this command with container name
docker port 
// USE the specific port
docker port
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are all the different built-in network drivers?

A
Bridge Network Driver
Overlay Network Driver
MACVLAN Driver
Host
None
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What are the Bridge network and its use case?

A

The bridge driver creates a private network internal to the host so containers on this network can communicate.The bridge driver does the service discovery for us automatically if two containers are on the same networkThe bridge driver is a local scope driver, which means it only provides service discovery, IPAM, and connectivity on a single host.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the scope of the bridge network?

A

local

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What are the Overlay network and their use case?

A

The built-in Docker overlay network driver radically simplifies many of the complexities in multi-host networking.It is a swarm scope driver, which means that it operates across an entire Swarm or UCP cluster rather than individual hosts.

17
Q

What is the scope of the overlay network?

A

swarm

18
Q

What are the MACVLAN network and their use case?

A

The macvlan driver is the newest built-in network driver and offers several unique characteristics. It’s a very lightweight driver, because rather than using any Linux bridging or port mapping, it connects container interfaces directly to host interfaces.

19
Q

What is the scope of the macvlan network?

A

local

20
Q

What are the Host network and its use case?

A

With the host driver, a container uses the networking stack of the host. There is no namespace separation, and all interfaces on the host can be used directly by the container.

21
Q

What is the scope of the host network?

A

local

22
Q

What are the None network and its use case?

A

The none driver gives a container its own networking stack and network namespace but does not configure interfaces inside the container. Without additional configuration, the container is completely isolated from the host networking stack.

23
Q

What is the scope of the None network?

A

local

24
Q

The Docker networking architecture is built on a set of interfaces called the Container Networking Model (CNM). Is this statement correct?

A

yes

25
Q

What is a sandbox in the CNM model?

A

A Sandbox contains the configuration of a container’s network stack. This includes the management of the container’s interfaces, routing table, and DNS settings. An implementation of a Sandbox could be a Windows HNS or Linux Network Namespace, a FreeBSD Jail, or other similar concept. A Sandbox may contain many endpoints from multiple networks.

26
Q

What is an endpoint in the CNM model?

A

An Endpoint joins a Sandbox to a Network. The Endpoint construct exists so the actual connection to the network can be abstracted away from the application. This helps maintain portability so that a service can use different types of network drivers without being concerned with how it’s connected to that network.

27
Q

What is a network in the CNM model?

A

The CNM does not specify a Network in terms of the OSI model. An implementation of a Network could be a Linux bridge, a VLAN, etc. A Network is a collection of endpoints that have connectivity between them. Endpoints that are not connected to a network do not have connectivity on a network.

28
Q

What part of the Docker that provides the actual implementation that makes networks work?

A

Network Drivers

29
Q

What is IPAM drivers?

A

Docker has a native IP Address Management Driver that provides default subnets or IP addresses for the networks and endpoints if they are not specified.

30
Q

How to configure docker to use external DNS?

A
//edit the /etc/docker/daemon.json
{       
   "dns":  ["10.0.0.2", "8.8.8.8"]
}
//restart the docker
sudo systemctl docker restart
31
Q

Which network should handles control and data traffic related to swarm services?

A

ingress

32
Q

Which network which connects the individual Docker daemon to the other daemons participating in the swarm?

A

docker_gwbridge

33
Q

What is the default network created when you create a swarm cluster?

A

ingress

34
Q

How to create a user-defined overlay network for communication among services?

A

docker network create -d overlay my-overlay

35
Q

How to create an overlay network which can be used by swarm services or standalone containers to communicate with other standalone containers running on other Docker daemons?

A

create with –attachable flag

docker network create -d overlay –attachable my-attachable-overlay

36
Q

All the swarm management data is encrypted by default. Is this statement correct?

A

yes

37
Q

is application data on the swarm encrypted by default?

A

No

38
Q

How to encrypt application data as well on the swarm?

A

// use –opt=encrypted

docker network create –opt encrypted –driver overlay –attachable my-attachable-multi-host-network

39
Q

What is the host port publishing mode?

A

To publish a service’s port directly on the node where it is running, use the mode=host option to the –publish flag.