[root@localhost ~]# docker -v
Docker version 1.13.1, build 64e9980/1.13.1
[root@localhost ~]# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl start docker
[root@localhost ~]#
[root@localhost ~]# docker -v
Docker version 1.13.1, build 64e9980/1.13.1
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost ~]#
Last login: Fri Aug 28 00:41:16 2020
[root@localhost ~]#
[root@localhost ~]# yum install -y docker
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
* base: mirrors.cn99.com
* extras: mirrors.163.com
* updates: mirrors.cn99.com
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/4): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/4): extras/7/x86_64/primary_db | 206 kB 00:00:00
(3/4): updates/7/x86_64/primary_db | 4.5 MB 00:00:00
(4/4): base/7/x86_64/primary_db | 6.1 MB 00:00:02
Resolving Dependencies
--> Running transaction check
。。。
[root@localhost ~]# docker -v
Docker version 1.13.1, build 64e9980/1.13.1
[root@localhost ~]# docker images
Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running?
[root@localhost ~]# systemctl enable docker
Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.
[root@localhost ~]# systemctl start docker
[root@localhost ~]#
[root@localhost ~]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
[root@localhost ~]#
[root@localhost ~]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
16cdbb645601 redis "docker-entrypoint..." 5 minutes ago Exited (0) 4 minutes ago redis-test
[root@localhost ~]# docker start 16cdbb645601
16cdbb645601
[root@localhost ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
16cdbb645601 redis "docker-entrypoint..." 6 minutes ago Up 6 seconds 0.0.0.0:6379->6379/tcp redis-test
[root@localhost ~]#
以下这些内容摘自http://www.gulixueyuan.com/ 网站提供的视频教程中的资料
1、搜索镜像
[root@localhost ~]# docker search tomcat
2、拉取镜像
[root@localhost ~]# docker pull tomcat
3、根据镜像启动容器
docker run --name mytomcat -d tomcat:latest
4、docker ps
查看运行中的容器
5、 停止运行中的容器
docker stop 容器的id
6、查看所有的容器
docker ps -a
7、启动容器
docker start 容器id
8、删除一个容器
docker rm 容器id
9、启动一个做了端口映射的tomcat
[root@localhost ~]# docker run -d -p 8888:8080 tomcat
-d:后台运行
-p: 将主机的端口映射到容器的一个端口 主机端口:容器内部的端口
10、为了演示简单关闭了linux的防火墙
service firewalld status ;查看防火墙状态
service firewalld stop:关闭防火墙
11、查看容器的日志
docker logs container-name/container-id
更多命令参看
https://docs.docker.com/engine/reference/commandline/docker/
可以参考每一个镜像的文档