卸载旧版(如果有的话):


$ sudo yum remove docker \
		  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine\

安装依赖包:

$ sudo yum install -y yum-utils \
           device-mapper-persistent-data \
           lvm2

安装doker:

$ sudo yum install docker

查看版本:

docker version
or
docker info

启动doker:

$ sudo systemctl enable docker
$ sudo systemctl start docker

下载镜像:

docker pull library/hello-world

查看镜像:

docker images

启动镜像:

docker run hello-world

查看运行镜像:

docker ps 或者 docker container ls 

查看所有镜像:

docker ps -a

启动、重启停止:

docker start container_name/container_id
docker restart container_name/container_id
docker stop container_name/container_id

进入容器:

docker attach container_name/container_id

运行这个容器中的镜像的话,并且调用镜像里面的 bash:

docker run -t -i container_name/container_id /bin/bash

删除容器:

docker rm container_name/container_id

删除镜像:

docker rmi image_name

创建镜像:

编辑DockerFile文件
vi DockerFile
	FROM openjdk:8-jre-alpine
	RUN mkdir -p /usr
	WORKDIR /usr/local/inf-fire
	ADD inf-fire.jar /usr/local/inf-fire
	EXPOSE 8092
	CMD ["java","-jar","inf-fire.jar"]
	
docker build -t inf-fire:v1.0.0 . 后面这个点表示在当前目录

保存导出:

将需要打包的jar和DockerFile文件放同一个文件夹,然后在文件目录执行
docker save -o inf-fire.tar inf-fire:v1.0.0

重启服务器后报错Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? 解决办法

$ systemctl daemon-reload
$ sudo service docker restart
$ sudo service docker status (should see active (running))