centos虚拟机安装
官网下载镜像
https://www.centos.org/download/
选择Minimal ISO
http://ftp.sjtu.edu.cn/centos/7.6.1810/isos/x86_64/CentOS-7-x86_64-Minimal-1810.iso
下载完成后镜像文件名
CentOS-7-x86_64-Minimal-1810.iso
在VM中安装镜像
普通安装即可
docker安装
检查系统内核
Docker 要求 CentOS 系统的内核版本高于 3.10
通过 uname -r 命令查看你当前的内核版本
[root@localhost ~]# uname -r
3.10.0-957.el7.x86_64
安装
Docker 软件包和依赖包已经包含在默认的 CentOS-Extras 软件源里,安装命令如下:
[root@localhost ~]# yum -y install docker
查看docker版本
[root@localhost ~]# docker version
Client:
Version: 1.13.1
API version: 1.26
...
启动docker
[root@localhost ~]# service docker start
创建用户及组
[root@localhost ~]# groupadd docker
[root@localhost ~]# useradd -g docker docker
运行helloworld
[root@localhost ~]# docker run hello-world
Unable to find image 'hello-world:latest' locally
Trying to pull repository docker.io/library/hello-world ...
latest: Pulling from docker.io/library/hello-world
1b930d010525: Pull complete
Digest: sha256:2557e3c07ed1e38f26e389462d03ed943586f744621577a99efb77324b0fe535
Status: Downloaded newer image for docker.io/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/
存出镜像
[root@localhost ~]# docker save -o /home/xf/hello.tar docker.io/hello-world:latest
载入镜像
[root@localhost opt]# ls
hello.tar
[root@localhost opt]# docker load < hello.tar
af0b15c8625b: Loading layer [==================================================>] 3.584 kB/3.584 kB
Loaded image: docker.io/hello-world:latest
查看容器
[root@localhost opt]# docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
ee386f20ddbd hello-world "/hello" 42 minutes ago Exited (0) 41 minutes ago focused_agnesi
6bda0bca8a33 hello-world "/hello" About an hour ago Exited (0) About an hour ago brave_franklin
删除容器
[root@localhost opt]# docker rm ee386f20ddbd
ee386f20ddbd
删除镜像
[root@localhost opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/hello-world latest fce289e99eb9 8 weeks ago 1.84 kB
[root@localhost opt]# docker rmi docker.io/hello-world
Untagged: docker.io/hello-world:latest
Deleted: sha256:fce289e99eb9bca977dae136fbe2a82b6b7d4c372474c9235adc1741675f587e
Deleted: sha256:af0b15c8625bb1938f1d7b17081031f649fd14e6b233688eea3c5483994a66a3
[root@localhost opt]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
查找并下载镜像
[root@localhost ddos_manager]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest 47b19964fb50 2 weeks ago 88.1 MB
docker.io/hello-world latest fce289e99eb9 8 weeks ago 1.84 kB
[root@localhost ddos_manager]# docker search -s 2 centos
Flag --stars has been deprecated, use --filter=stars=3 instead
INDEX NAME DESCRIPTION STARS OFFICIAL AUTOMATED
docker.io docker.io/centos The official build of CentOS. 5209 [OK]
docker.io docker.io/ansible/centos7-ansible Ansible on Centos7 120 [OK]
docker.io docker.io/jdeathe/centos-ssh CentOS-6 6.10 x86_64 / CentOS-7 7.5.1804 x... 106 [OK]
docker.io docker.io/consol/centos-xfce-vnc Centos container with "headless" VNC sessi... 81 [OK]
docker.io docker.io/imagine10255/centos6-lnmp-php56 centos6-lnmp-php56 50 [OK]
docker.io docker.io/centos/mysql-57-centos7 MySQL 5.7 SQL database server 47
docker.io docker.io/tutum/centos Simple CentOS docker image with SSH access 43
docker.io docker.io/gluster/gluster-centos Official GlusterFS Image [ CentOS-7 + Glu... 40 [OK]
docker.io docker.io/openshift/base-centos7 A Centos7 derived base image for Source-To... 39
docker.io docker.io/centos/postgresql-96-centos7 PostgreSQL is an advanced Object-Relationa... 37
docker.io docker.io/centos/python-35-centos7 Platform for building and running Python 3... 33
docker.io docker.io/kinogmt/centos-ssh CentOS with SSH 25 [OK]
docker.io docker.io/centos/httpd-24-centos7 Platform for running Apache httpd 2.4 or b... 21
docker.io docker.io/openshift/jenkins-2-centos7 A Centos7 based Jenkins v2.x image for use... 20
docker.io docker.io/centos/php-56-centos7 Platform for building and running PHP 5.6 ... 19
docker.io docker.io/pivotaldata/centos-gpdb-dev CentOS image for GPDB development. Tag nam... 10
docker.io docker.io/openshift/wildfly-101-centos7 A Centos7 based WildFly v10.1 image for us... 6
docker.io docker.io/openshift/jenkins-1-centos7 DEPRECATED: A Centos7 based Jenkins v1.x i... 4
docker.io docker.io/darksheer/centos Base Centos Image -- Updated hourly 3 [OK]
docker.io docker.io/pivotaldata/centos Base centos, freshened up a little with a ... 2
docker.io docker.io/pivotaldata/centos-mingw Using the mingw toolchain to cross-compile... 2
[root@localhost ddos_manager]#
[root@localhost ddos_manager]#
[root@localhost ddos_manager]#
[root@localhost ddos_manager]# docker pull centos
Using default tag: latest
Trying to pull repository docker.io/library/centos ...
latest: Pulling from docker.io/library/centos
a02a4930cb5d: Pull complete
Digest: sha256:184e5f35598e333bfa7de10d8fb1cebb5ee4df5bc0f970bf2b1e7c7345136426
Status: Downloaded newer image for docker.io/centos:latest
[root@localhost ddos_manager]#
[root@localhost ddos_manager]# docker images
REPOSITORY TAG IMAGE ID CREATED SIZE
docker.io/ubuntu latest 47b19964fb50 3 weeks ago 88.1 MB
docker.io/hello-world latest fce289e99eb9 8 weeks ago 1.84 kB
docker.io/centos latest 1e1148e4cc2c 2 months ago 202 MB
[root@localhost ddos_manager]#