前言:
而今我们对“ubuntu安bdocker”都比较关注,你们都想要学习一些“ubuntu安bdocker”的相关资讯。那么小编同时在网络上网罗了一些对于“ubuntu安bdocker””的相关资讯,希望咱们能喜欢,看官们快快来学习一下吧!第一步:安装
apt-get update apt-get install apt-transport-https ca-certificates curl software-properties-common
第二步骤:安装国内的镜像源
curl -fsSL | sudo apt-key add -sudo add-apt-repo sitory "deb [arch=amd64] $(lsb_release -cs) stable"
第三步:安装docker
apt-get updateapt-get install docker-ce
注:ifconfig查看确保docker0网卡有IP地址
第四步:具体操作
查看镜像 docker images
搜索靶机 docker search ctf
例如下载镜像 docker pull duwentao/sql-injection:2.0
下载慢,解决办法参考:
第五步:运行镜像
root@yana:/# docker ps -a #运行前查看镜像
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
root@yana:/# docker run -dt -p 8080:80 duwentao/sql-injection:2.0
f6450b4e8ad5a10916b28eb1c139e436ea9b8ec6b668e662ab4c0afa0d628eae
root@yana:/# docker ps -a #运行后查看镜像
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
f6450b4e8ad5 duwentao/sql-injection:2.0 "/bin/bash" 5 seconds ago Up 4 seconds 22/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp dreamy_kalam
进入docker虚拟机里 docker exec -it 容器ID bash
root@yana:/# docker exec -it f6450b4e8ad5 bash
[root@f6450b4e8ad5 /]# ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:AC:11:00:02
inet addr:172.17.0.2 Bcast:172.17.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
在dcoker容器(虚拟机)里启动web服务 ifconfig 、 netstat -ntl 、 service httpd restart 、service mysqld restart
[root@f6450b4e8ad5 /]# netstat -ntl
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
[root@f6450b4e8ad5 /]# service httpd restart
Stopping httpd: [ OK ]
Starting httpd: [ OK ]
[root@f6450b4e8ad5 /]# service httpd status
httpd (pid 86) is running...
[root@f6450b4e8ad5 /]# service mysqld restart
Stopping mysqld: [FAILED]
Starting mysqld: [ OK ]
[root@f6450b4e8ad5 /]# service mysqld status
mysqld (pid 262) is running...
访问启动的服务
删除运行的容器 docker rm -f 容器ID 、docker ps -a
删除镜像docker images 、docker rmi REPOSITY:TAG、docker images
第七步:docker镜像打包 和导出、导入tar包
docker commit 容器ID tar包名、docker images、
docker save -o ./test.tar test:latest #把镜像导出为tar包
docker load --input ./test.tar #导入镜像包
第八步:安装docker-compose
curl -L -`uname -s`-`uname -m` > /usr/local/bin/docker-composechmod +x /usr/local/bin/docker-compose
root@yana:~# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
c5f6d338a484 webadmin_web "node /usr/app/index…" 10 minutes ago Up 10 minutes 0.0.0.0:2333->4000/tcp, :::2333->4000/tcp webadmin_web_1
f6450b4e8ad5 duwentao/sql-injection:2.0 "/bin/bash" 2 hours ago Up 2 hours 22/tcp, 0.0.0.0:8080->80/tcp, :::8080->80/tcp dreamy_kalam
root@yana:~#
访问启动的服务
标签: #ubuntu安bdocker