亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定

Docker

標簽:
Docker

移除旧的版本

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

安装一些必要的系统工具

yum install -y yum-utils device-mapper-persistent-data lvm2

添加软件源信息

yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

更新 yum 缓存

yum makecache fast

安装 Docker-ce

yum -y install docker-ce

启动Docker后台服务

systemctl start docker

测试运行 hello-world

docker run hello-world

运行结果

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:0e11c388b664df8a27a901dce21eb89f11d8292f7fca1b3e3c4321bf7897bffe
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the “hello-world” image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

Docker运行nginx

  1. 拉取镜像

docker pull hub.c.163.com/library/nginx:latest
  1. 以后台运行nginx,并指定端口映射。- -name指定容器名称,如果不指定,默认会随机生成一个名称,-d代表后台运行,8080是指主机端口,80为容器端口

docker run --name nginx-test -d -p 8080:80 hub.c.163.com/library/nginx
  1. 使用docker ps命令查看运行的容器

CONTAINER IDIMAGEPORTSNAMES
4f1523ef4d16hub.c.163.com/library/nginx0.0.0.0:8080->80/tcpnginx-test
  1. 浏览器输入ip:8080即可访问到nginx页面

常用命令

  1. 拉取镜像,TAG是版本号的意思

docker pull [OPTIONS] NAME[:TAG]
  1. 查看本机有哪些镜像,[REPOSITORY [:TAG]]指定镜像名称和TAG

docker images [OPTIONS] [REPOSITORY [:TAG]]
  1. 删除镜像

docker rmi IMAGEID
  1. 强制删除镜像

docker rmi -f IMAGEID
  1. 运行docker,COMMAND是指要执行的命令,ARG…是指命令依赖的参数

docker run [OPTIONS] IMAGE[:TAG] [COMMAND] [ARG…]
  1. 查看机器上运行的容器

docker ps
  1. 查看机器上运行过的容器

docker ps -a
  1. 进入运行的容器

docker exec -it CONTAINERID /bin/bash
  1. 停止容器

docker stop CONTAINERID
  1. 启动容器

docker start CONTAINERID
  1. 停用全部运行中的容器

docker stop KaTeX parse error: Expected 'EOF', got '&' at position 8: (docker&̲nbsp;ps -q…(docker ps -aq)
  1. 一条命令实现停用并删除容器

docker stop KaTeX parse error: Expected 'EOF', got '&' at position 8: (docker&̲nbsp;ps -q…(docker ps -aq)


點擊查看更多內容
TA 點贊

若覺得本文不錯,就分享一下吧!

評論

作者其他優質文章

正在加載中
  • 推薦
  • 評論
  • 收藏
  • 共同學習,寫下你的評論
感謝您的支持,我會繼續努力的~
掃碼打賞,你說多少就多少
贊賞金額會直接到老師賬戶
支付方式
打開微信掃一掃,即可進行掃碼打賞哦
今天注冊有機會得

100積分直接送

付費專欄免費學

大額優惠券免費領

立即參與 放棄機會
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號

舉報

0/150
提交
取消