Docker
2018-12-10 本文已影响0人
炼心之旅
- 获取Docker安装包
wget -qO- https://get.docker.com/ | sh
命令执行之后,docker自动安装,完成后执行 docker -v 查看是否安装成功
注意:
安装完成之后会有下列提示
If you would like to use Docker as a non-root user, you should now consider
adding your user to the "docker" group with something like:
sudo usermod -aG docker wnn
Remember that you will have to log out and back in for this to take effect!
WARNING: Adding a user to the "docker" group will grant the ability to run
containers which can be used to obtain root privileges on the
docker host.
Refer to https://docs.docker.com/engine/security/security/#docker-daemon-attack-surface
for more information.
- 执行命令:sudo usermod -aG docker wnn
- 用户切换为root
- Docker命令:
a. 搜索镜像:docker search XXX
b. 拉取镜像:docker pull XXX
c. 查看本地主机的已有镜像:docker images
d. 查看镜像详细信息:docker inspect
e. 删除镜像:docker rmi docker.io/ubuntu
f. 创建镜像:docker run -ti ubuntu /bin/bash - Docker 操作:
a. 直接运行容器中的程序:docker run ubuntu:15.10 /bin/echo "Hello world"
b. 运行交互式容器:docker run -i -t jenkins/jenkins /bin/bash
c. 查看运行中的容器:docker ps
d. 停止容器:docker stop containerId
e. 映射端口:-p docker run -i -t -p 8080 jenkins/Jenkins 32768是localhost访问端口
i. root@wnn-virtual-machine:/home/wnn# docker port eea861e45ebc
ii. 8080/tcp -> 0.0.0.0:32768
f. 访问web服务