Lab 5.A - Resources
Image Source: Docker
docker run -d -p 8080:80 --name nginx1 nginx:alpine
services:
nginx:
image: nginx:alpine
container_name: nginx1
ports:
- "8080:80"
curl localhost:8080
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a1ef8911ce52 nginx:alpine "/docker-entrypoint.…" 8 minutes ago Up 8 minutes 0.0.0.0:8080->80/tcp nginx1
Image Source: Docker
docker run -d -p 8080:80 --name nginx1 nginx:alpine
docker network create -d bridge --internal redis_network
docker network connect redis_network nginx1
docker run -d --name redis1 --network redis_network redis:latest
services:
nginx:
image: nginx:alpine
container_name: nginx1
ports:
- "8080:80"
networks:
- redis_network
- default
redis:
image: redis:latest
container_name: redis1
networks:
- redis_network
networks:
redis_network:
internal: true
docker network inspect [network]
[ {
"Name": "docker_default",
...
"Containers": {
"a1ef8911ce524b8345c0e047798072c4cba2c6bb1a2dafd4a37e9b577b2c34d0": {
"Name": "nginx1",
"EndpointID": "716dec048ad8b8ccdab793cceb93881c775af5335671555b3c437b395fde35dd",
"MacAddress": "02:42:ac:15:00:02",
"IPv4Address": "172.21.0.2/16",
"IPv6Address": ""
} } } ]
[ {
"Name": "docker_redis_network",
// ...
"Containers": {
"a1ef8911ce524b8345c0e047798072c4cba2c6bb1a2dafd4a37e9b577b2c34d0": {
"Name": "nginx1",
"EndpointID": "af8f3f616491df592fbc21d665e51e7a7f6989abc557e76ea56bf7c71158db00",
"MacAddress": "02:42:ac:14:00:03",
"IPv4Address": "172.20.0.3/16",
"IPv6Address": ""
},
"bfa602ef48b0fe744d59d2c450f271ad108cae23c7cb5f2b4f021961db25a978": {
"Name": "redis1",
"EndpointID": "a0a761e9c91282bbb7715428385182f2dddcf0022c1f66731a91135a243bde19",
"MacAddress": "02:42:ac:14:00:02",
"IPv4Address": "172.20.0.2/16",
"IPv6Address": ""
} } } ]
Image Source: Vladislav Supalov
docker network create -d bridge --internal mysql_network
docker network create -d bridge mysql_default
docker run -d --name mysql1 --network mysql_network
-e MYSQL_ROOT_PASSWORD=password mysql:latest
docker run -d --name mysqladmin1 --network mysql_default
-e PMA_HOST=mysql1 -p 8080:80 phpmyadmin/phpmyadmin:latest
docker network connect mysql_network mysqladmin1
services:
mysql:
image: mysql:latest
container_name: mysql1
networks:
- mysql_network
environment:
MYSQL_ROOT_PASSWORD: password
mysqladmin:
image: phpmyadmin/phpmyadmin:latest
container_name: mysqladmin1
ports:
- "8080:80"
networks:
- default
- mysql_network
environment:
PMA_HOST: mysql1
networks:
mysql_network:
internal: true
docker inspect [container]
[ {
// ...
"Name": "/mysql1",
// ...
"Config": {
// ...
"Env": [
"MYSQL_ROOT_PASSWORD=password",
"PATH=/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin",
"GOSU_VERSION=1.14",
"MYSQL_MAJOR=8.0",
"MYSQL_VERSION=8.0.29-1debian10"
],
// ...
"Image": "mysql:latest",
// ...
}
} ]
docker compose down
docker compose up -d
Image Source: Docker
mkdir /home/cis527/mysql
docker run -d --name mysql1 --network mysql_network
-e MYSQL_ROOT_PASSWORD=password
-v /home/cis527/mysql:/var/lib/mysql
mysql:latest
services:
mysql:
image: mysql:latest
container_name: mysql1
networks:
- mysql_network
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- /home/cis527/mysql:/var/lib/mysql
# ...
docker volume create mysql_data
docker run -d --name mysql1 --network mysql_network
-e MYSQL_ROOT_PASSWORD=password
-v mysql_data:/var/lib/mysql
mysql:latest
services:
mysql:
image: mysql:latest
container_name: mysql1
networks:
- mysql_network
environment:
MYSQL_ROOT_PASSWORD: password
volumes:
- mysql_data:/var/lib/mysql
# ...
volumes:
mysql_data:
docker inspect [container]
[ {
// ...
"Name": "/mysql1",
// ...
"Mounts": [
{
"Type": "volume",
"Name": "docker_mysql_data",
"Source": "/var/lib/docker/volumes/docker_mysql_data/_data",
"Destination": "/var/lib/mysql",
"Driver": "local",
"Mode": "z",
"RW": true,
"Propagation": ""
}
]
} ]