Complete the code to specify the network mode for a Docker container.
docker run --network=[1] myappThe bridge network mode is the default Docker network mode that allows containers to communicate on a private internal network.
Complete the code to expose a container port to the host machine.
docker run -p [1]:80 myapp
Port 8080 on the host is mapped to port 80 inside the container, allowing external access.
Fix the error in the Docker Compose service network configuration.
services:
web:
image: myapp
networks:
- [1]
networks:
frontend:
driver: bridgeThe service must connect to the defined network frontend to communicate properly.
Fill both blanks to create a Docker network and connect a container to it.
docker network [1] mynet docker run --network=[2] myapp
First, create the network named mynet using create. Then run the container connected to mynet.
Fill all three blanks to define a Kubernetes Pod with two containers sharing a network.
apiVersion: v1
kind: Pod
metadata:
name: mypod
spec:
containers:
- name: app
image: myapp
ports:
- containerPort: [1]
- name: sidecar
image: sidecar
ports:
- containerPort: [2]
[3]The app container listens on port 80, the sidecar on 8080. Setting hostNetwork: true allows both containers to share the host network.