Docker(2):安装和基本操作

一、docker 安装

1.系统环境CentOS7.4

2.安装步骤

(1)查看内核是否支持docker

Docker 要求 CentOS 系统的内核版本高于 3.10 ,查看本页面的前提条件来验证你的CentOS 版本是否支持 Docker 。

uname -r

3.10.0-693.11.1.el7.x86_64

(2)安装 Docker

yum -y install docker

(3)查看docker版本

docker version

(4)启动 Docker 后台服务

systemctl start docker

(6)开机启动

systemctl enable docker

(7)测试运行 hello-world,由于本地没有hello-world这个镜像,所以会下载一个hello-world的镜像,并在容器内运行。

docker run hello-world

运行结果

[root@hadoop02 Jpress]# docker run hello-world

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常用命令

1.查看本地镜像

docker images

2.拉取镜像

docker pull 镜像名称

3.查看运行镜像

docker ps

4.运行镜像

docker run [OPTIONS] IMAGE[:TAG][COMMAND][ARG…]

例如:

docker run hello-world

5.停止镜像

docker stop 镜像名称

6.删除本地镜像

(1)删除镜像

docker  rmi <image id>

(2)删除容器

Docker rm <image id>

猜你喜欢

转载自blog.csdn.net/u010886217/article/details/88769140