下载yum文件
wget https://mirrors.tuna.tsinghua.edu.cn/docker-ce/linux/centos/docker-ce.repovim docker-ce.repo
把里面的网址替换为国内docker安装的网址 (%s@s_content@d_content@)https://mirrors.tuna.tsinghua.edu.cn/docker-ce安装:
yum install docker-ce做仓库加速
mkdir /etc/docker && vim daemon.json{ "registry-mirrors": ["https://registry.docker-cn.com"]}启动
systemctl start docker.service命令:
docker versiondocker infodocker --helpdocker search nginx alpine 用于微小环境使用的版本 (测试使用,一般都不带调试工具)docker image pull nginx:1.14-alpine 拉取nginx:1.14-alpine镜像(下载到本地)
docker image ls 显示本地业务镜像
docker container create Create a new container
start Start one or more stopped containers stop Stop one or more running container kill Kill one or more running containers (强行停止) rm Remove one or more containers run Run a command in a new container ls List containers#docker container run --help Usage: docker container run [OPTIONS] IMAGE [COMMAND] [ARG... [root@localhost docker]# docker network ls (默认是加入到bridge) --net桥NETWORK ID NAME DRIVER SCOPE88ff822f6fb8 bridge bridge localf9d368813f78 host host locale89e4a2ba752 none null local# docker inspect b2 查看容器b2的配置文件docker container ls -a 查看所有容器
[root@localhost docker]# docker start --help 激活停之状态的容器
Usage: docker start [OPTIONS] CONTAINER [CONTAINER...]
Start one or more stopped containers
Options:
-a, --attach Attach STDOUT/STDERR and forward signals --detach-keys string Override the key sequence for detaching a container -i, --interactive Attach container's STDIN[root@localhost docker]# docker container start -a -i b2
[root@localhost docker]# docker container rm b2 删除停止状态的容器
[root@localhost docker]# docker container run --name web1 -d nginx:1.14-alpine 创建一个nginx容器
docker container ps 查看容器CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES2b467342ac21 nginx:1.14-alpine "nginx -g 'daemon of…" 45 seconds ago Up 44 seconds 80/tcp [root@localhost docker]# docker container run --name kvstor1 -d redis:4-alpine[root@localhost docker]# docker container exec -it kvstor1 /bin/sh 进入容器查看业务运行情况
/data # psPID USER TIME COMMAND 1 redis 0:00 redis-server 12 root 0:00 /bin/sh 17 root 0:00 ps/data # netstat -tnlActive Internet connections (only servers)Proto Recv-Q Send-Q Local Address Foreign Address State tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN tcp 0 0 :::6379 :::* LISTEN/data # redis-cli
[root@localhost docker]# docker logs web1 日志查看 web1