Docker Network
bridge,none,host
Q:Run a container named alpine-2 using the alpine image and attach it to the none network.
A:docker run -d --name alpine-2 --network=none alpine
Q:Create a new network named wp-mysql-network using the bridge driver. Allocate subnet 182.18.0.1/24. Configure Gateway 182.18.0.1
A:docker network create --driver bridge --subnet 182.18.0.1/24 --gateway 182.18.0.1 wp-mysql-network
Q:Deploy a mysql database using the mysql:5.6 image and name it mysql-db. Attach it to the newly created network wp-mysql-network
Set the database password to use db_pass123. The environment variable to set is MYSQL_ROOT_PASSWORD
A:docker run -d --name mysql-db -e MYSQL_ROOT_PASSWORD=db_pass123 --network wp-mysql-network mysql:5.6
A:docker run -d --name webapp --link mysql-db:mysql-db -e DB_Host=mysql-db -e DB_Password=db_pass123 -p 38080:8080 --network=wp-mysql-network kodekloud/simple-webapp-mysql
Docker Registry
Q:Let practice deploying a registry server on our own.
Run a registry server with name equals to my-registry using registry:2 image with host port set to 5000, and restart policy set to always.
Note: Registry server is exposed on port 5000 in the image.
Here we are hosting our own registry using the open source Docker Registry.
A:docker run -d --name my-registry --restart=always -p 5000:5000 registry:2
Q:Now its time to push some images to our registry server. Let’s push two images for now .i.e. nginx:latest and httpd:latest.
Note: Don’t forget to pull them first.
To check the list of images pushed , use curl -X GET localhost:5000/v2/_catalog
A:
1、 docker pull nginx:latest
2、 docker image tag nginx:latest localhost:5000/nginx:latest
3、 docker push localhost:5000/nginx:latest.
We will use the same steps for the second image docker pull httpd:latest and then docker image tag httpd:latest localhost:5000/httpd:latest and finally push it using docker push localhost:5000/httpd:latest