bridge: The default network driver.host: Remove network isolation between the container and the Docker host.none: Completely isolate a container from the host and other containers.overlay: Overlay networks connect multiple Docker daemons together.ipvlan: IPvlan networks provide full control over both IPv4 and IPv6 addressing.macvlan: Assign a MAC address to a container.docker network will list all possible command options
docker network ls will list all possible networks
bridge compute, csc418env_default, docker-spark_default, and docker_default: Dr. Ngo’s custom networksdocker network inspect NAME: inspect the NAME network
bridge network
1
docker run -itd node:slim
bridge network to learn about the container.
1
docker run -itd --name my_nodejs node:slim
1
docker ps
docker exec
1
docker exec -it my_nodejs sh
my_nodejs container, install nano and curl:
1
2
apt update
apt install -y nano curl
app under the root directory. Use nano to create a file called server.js with the following contents```js linenums=”1” const { createServer } = require(‘node:http’); const hostname = ‘0.0.0.0’; const port = 3000; const server = createServer((req, res) => { res.statusCode = 200; res.setHeader(‘Content-Type’, ‘text/plain’); res.end(‘Hello World’); }); server.listen(port, hostname, () => { console.log(Server running at http://${hostname}:${port}/); });
1
2
3
4
5
6
- Launch the server using the following commands
```bash
cd /app
node server.js
docker exec to get into the running my_nodejs container.curl 127.0.0.1:3000. What is the outcome?127.0.0.1:3000. What is the outcome?my_nodejs container.my_nodejs:1.0. This is for the next step of the hands-on
my_nodejs:1.0 image
1
2
3
docker run -itd -P --expose 3000 --name my_nodejs my_nodejs:1.0 sh
cd /app
node server.js
docker ps or the Docker Desktop dashboard127.0.0.1 at the shown mapped port (most likely 5 digits)-P: make this service reachable from other computers (--publish-all)--expose : Open a port from inside the container
-p flag as follows:
1
docker run -itd -p 30080:3000 --expose 3000 --name my_nodejs my_nodejs:1.0 sh
port-on-host:port-on-container -p flag.127.0.0.1:30080 to confirm that the Node server inside the container is still reachable.docker from the main branch.docker branch contains all files from Dr. Ngo’s cloudlab repository’s docker branch.Edit and Update the link to the GitHub repository.docker added to the Repository Branches and Tags of your CloudLab profile.Instantiate button for this branch.
localhost or 127.0.0.1.
1
2
docker network create --driver bridge ramnet
docker network ls
1
2
docker run -d --name es --net ramnet elasticsearch:2
docker network inspect ramnet
1
2
docker run -it --net ramnet alpine sh
ping es
ramnet