docker/k8s(1):docker安装使用
依赖docker使用安装docker使用yum安装最新版本dockeryum install docker查看docker版本[root@localhost ~]# docker versionClient:Version:1.13.1API version:1.26Package version:Cannot connect to the Docker daemon at unix:///var
·
欢迎关注本人公众号
依赖
docker使用
安装docker
使用yum安装最新版本docker
yum install docker
查看docker版本
[root@localhost ~]# docker version
Client:
Version: 1.13.1
API version: 1.26
Package version:
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
下载tomcat
[root@localhost ~]# docker pull tomcat
Using default tag: latest
Trying to pull repository docker.io/library/tomcat ...
latest: Pulling from docker.io/library/tomcat
e9afc4f90ab0: Pull complete
989e6b19a265: Pull complete
af14b6c2f878: Pull complete
5573c4b30949: Pull complete
fb1a405f128d: Pull complete
612a9f566fdc: Pull complete
cf63ebed1142: Pull complete
fbb20561cd50: Pull complete
e99c920870d7: Pull complete
b7f793f2be47: Pull complete
Digest: sha256:81c2a95e5b1b5867229d75255abe54928d505deb81c8ff8949b61fde1a5d30a1
Status: Downloaded newer image for docker.io/tomcat:latest
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/tomcat latest 2eb5a120304e 3 weeks ago 647 MB
docker images
查看本地仓库有哪些镜像。
启动tomcat
[root@localhost ~]# docker run -d -p 80:8080 tomcat:latest
162820979bc3ca1e9958b548ef06262ac34e2ddd9010b10ee52bfdf3a6ffca58
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
162820979bc3 tomcat:latest "catalina.sh run" About a minute ago Up About a minute 0.0.0.0:80->8080/tcp eloquent_spence
上面设置了端口映射,虚拟机的80端口映射到docker容器的tomcat的8080端口。这样就可以在虚拟机外部访问docker的内容了。
下图可以看到正常访问到tomcat了,但是不知道为何tomcat返回了404。
停止容器
[root@localhost ~]# docker stop 162820979bc3
162820979bc3
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
服务停止后就无法再访问tomcat了:
更多推荐
已为社区贡献2条内容
所有评论(0)