kodekould docker练习

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
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值