Docker 安装

Posted luckyleaf

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Docker 安装相关的知识,希望对你有一定的参考价值。

docker安装

Ubuntu系统(脚本安装)

[email protected]:~$sudo wget -qO- https://get.docker.com | sh
[email protected]:~$sudo usermod -aG docker v2admin // 如果使用非root用户,需要赋予下权限,然后重新登录

启动Docker

[email protected]:~$ sudo service docker start

镜像加速

[email protected]:~$ sudo vim /etc/docker/daemon.json

    "registry-mirrors": ["http://hub-mirror.c.163.com"]

启动httpd容器

[email protected]:~$ sudo docker run -d -p 80:80 httpd
Unable to find image 'httpd:latest' locally
latest: Pulling from library/httpd
fc7181108d40: Pull complete 
b183a5e3b6da: Pull complete 
c52952f0d826: Pull complete 
c8f255a56e9a: Pull complete 
144c3b858b48: Pull complete 
Digest: sha256:a129c3a747fe9e406bf91d4d1fb2d4ed7b51d7a1f523fcf372c18c3c35981d12
Status: Downloaded newer image for httpd:latest
533c723b96c6ee52836e9e7a709abba09a46ab93c1a15dd798da920169a482fe
//大致过程,本地没有找到httpd的镜像,然后下载httpd image,image中已经安装好了apache服务。
//启动httpd服务,将容器的80端口映射到host的80端口  

[email protected]:~$ docker images //查看镜像
REPOSITORY TAG IMAGE ID CREATED SIZE
httpd latest e77c77f17b46 2 weeks ago 140MB
hello-world latest fce289e99eb9 5 months ago

[email protected]:~$ docker container ls   //查看运行的容器
CONTAINER ID        IMAGE               COMMAND              CREATED              STATUS                    PORTS                NAMES
c5e83f95908a        httpd               "httpd-foreground"   About a minute ago   Up About a minute       0.0.0.0:80->80/tcp   sleepy_hawking
[email protected]:~$ docker ps   //查看运行的容器
CONTAINER ID        IMAGE               COMMAND              CREATED              STATUS              PORTS                NAMES
c5e83f95908a        httpd               "httpd-foreground"   About a minute ago   Up About a minute   0.0.0.0:80->80/tcp   sleepy_hawking

以上是关于Docker 安装的主要内容,如果未能解决你的问题,请参考以下文章

shell bash如何判断docker是否安装(检测docker安装检查docker安装docker版本)

Debian11安装docker

Docker教程-1-学习及安装Docker

Docker教程-1-学习及安装Docker

Docker——Docker基础+Docker安装

CentOS8.1安装docker