docker镜像文件下载_docker安装centos7镜像

docker镜像文件下载_docker安装centos7镜像1安装docker的apt源apt-getinstallapt-transport-httpsca-certificatescurlsoftware-properties-common

大家好,又见面了,我是你们的朋友全栈君。如果您正在找激活码,请点击查看最新教程,关注关注公众号 “全栈程序员社区” 获取激活教程,可能之前旧版本教程已经失效.最新Idea2022.1教程亲测有效,一键激活。

Jetbrains全系列IDE使用 1年只要46元 售后保障 童叟无欺

 

1 安装dockerapt

apt-get install apt-transport-https ca-certificates curl software-properties-common

2 添加docker官方的GPG

root@zhf-linux:/home# curl -s https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add –

OK

3 添加docker的源。如果没有docker.list则自己创建一个

root@zhf-linux:/etc/apt/sources.list.d# bash -c “echo deb https://get.docker.io/ubuntu docker main > /etc/apt/sources.list.d/docker.list”

4 安装docker

apt install docker.io

5 查看docker的版本:

root@zhf-linux:/var/lib/docker# docker version

Client:

Version: 1.13.1

API version: 1.26

Go version: go1.6.2

Git commit: 092cba3

Built: Thu Sep 7 17:23:05 2017

OS/Arch: linux/386

Server:

Version: 1.13.1

API version: 1.26 (minimum version 1.12)

Go version: go1.6.2

Git commit: 092cba3

Built: Thu Sep 7 17:23:05 2017

OS/Arch: linux/386

Experimental: false

到这里docker整个就安装完了,我们来看下如何来启动一个镜像

1 通过docker run命令来启动一个httpd的镜像。如果没有发现httpd镜像会从docker hub下载镜像。下载完成后,镜像httpd被保存到本地

docker run -d -p 80:80 httpd

2 docker images可以看到已经下载到本地

root@zhf-linux:/home/zhf/zhf/c_prj/make_function# docker images

REPOSITORY TAG IMAGE ID CREATED SIZE

httpd latest 7659d5a9a057 2 weeks ago 189 MB

3 docker ps显示容器正在运行

root@zhf-linux:/home/zhf/zhf/c_prj/make_function# docker ps

CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES

39ae70ca12b2 httpd “httpd-foreground” 6 minutes ago Up 6 minutes 0.0.0.0:80->80/tcp compassionate_bohr

接下来看下如何下载一个镜像。通过docker pull下载。docker pull会从Docker Hub进行下载。

root@zhf-linux:/home/zhf/zhf/c_prj/make_function# docker pull hello-world

Using default tag: latest

latest: Pulling from library/hello-world

cf7dde121f94: Pull complete

Digest: sha256:0e06ef5e1945a718b02a8c319e15bae44f47039005530bc617a5d071190ed3fc

Status: Downloaded newer image for hello-world:latest

通过docker images看到这个镜像只有600K

root@zhf-linux:/home/zhf/zhf/c_prj/make_function# docker images hello-world

REPOSITORY TAG IMAGE ID CREATED SIZE

hello-world latest abd130ec0722 3 months ago 665 kB

通过docker run hello-world来执行。结果如下:

root@zhf-linux:/home/zhf/zhf/c_prj/make_function# 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.

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://cloud.docker.com/

For more examples and ideas, visit:

https://docs.docker.com/engine/userguide/

下载的docker镜像默认存储路径是/var/lib/docker .具体的镜像文件就在containers文件夹中

root@zhf-linux:/var/lib/docker# ls -al

total 44

drwx–x–x 11 root root 4096 Oct 30 22:28 .

drwxr-xr-x 79 root root 4096 Dec 11 21:08 ..

drwx—— 5 root root 4096 Oct 30 22:28 aufs

drwx—— 8 root root 4096 Dec 19 20:59 containers

drwx—— 3 root root 4096 Oct 30 22:28 image

drwxr-x— 3 root root 4096 Oct 30 22:28 network

drwx—— 4 root root 4096 Oct 30 22:28 plugins

drwx—— 2 root root 4096 Oct 30 22:28 swarm

drwx—— 2 root root 4096 Dec 19 20:50 tmp

drwx—— 2 root root 4096 Oct 30 22:28 trust

drwx—— 2 root root 4096 Oct 30 22:28 volumes

 

 

Dockerfile是镜像的描述文件,定义了如何构建Docker镜像。Dockerfile需要到docker网站去查看:

 

https://hub.docker.com/

 

查看方法如下:

 

1 首先在网站上注册一个docker账号

 

2 在上面的搜索栏中输入hello-world

docker镜像文件下载_docker安装centos7镜像

3 得到仓库中所有关于hello world的镜像,第一个就是我们下载的镜像

 docker镜像文件下载_docker安装centos7镜像

4 点击进入后,会发现如下的dockerfile链接

docker镜像文件下载_docker安装centos7镜像

5 点击进入后跳转到github上的链接,可以看到hello-worlddockerfile写法

docker镜像文件下载_docker安装centos7镜像

 

docker镜像文件下载_docker安装centos7镜像

 

 

 

 

 

 

 

 

 

 

只有短短三条指令。

      1. FROM scratch
        此镜像是从白手起家,从 0 开始构建。

      2. COPY hello /
        将文件“hello”复制到镜像的根目录。

      3. CMD [“/hello”]
        容器启动时,执行 /hello

镜像 hello-world 中就只有一个可执行文件 “hello”,其功能就是打印出 “Hello from Docker ……” 等信息。

/hello 就是文件系统的全部内容,连最基本的 /bin/usr, /lib, /dev 都没有。 而/hello是根据hello.c编译而来的。可以点进去看下hello.c的内容,其实就是打印我们刚才执行docker run hello-world的内容。

docker镜像文件下载_docker安装centos7镜像

 

版权声明:本文内容由互联网用户自发贡献,该文观点仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请联系我们举报,一经查实,本站将立刻删除。

发布者:全栈程序员-站长,转载请注明出处:https://javaforall.net/167745.html原文链接:https://javaforall.net

(0)
全栈程序员-站长的头像全栈程序员-站长


相关推荐

  • docker安装Lefse和分析流程[通俗易懂]

    docker安装Lefse和分析流程[通俗易懂]linux通过docker安装lefse默认你已经安装好docker!下载lefse镜像文件dockerrun-itbiobakery/lefsebash启动docker的lefse镜像,并且把主机文件夹挂载到镜像,这样可以在镜像中看到主机中的文件夹,下面是吧主机中的Data文件夹挂在到镜像(shared文件夹需要自己建),更改Data权限shared权限也会改变…

    2022年5月28日
    36
  • docker搭建kafka集群

    docker搭建kafka集群docker搭建kafka集群我在M1mbp上使用的以下镜像新建文件zk-kafka-docker-compose.ymlversion:”2″services:zookeeper:user:rootimage:docker.io/zookeeperports:-“12181:2181″environment:-ALLOW_ANONYMOUS_LOGIN=yesvolumes:-zoo

    2022年4月25日
    31
  • 使用docker启动mysql8.0挂载配置文件_docker的特点

    使用docker启动mysql8.0挂载配置文件_docker的特点使用docker启动MySQL8.0因为mysql8对登录密码的加密方式做了调整,所以每次安装完mysql都要去翻翻教程,特此记录下,方便以后查看docker启动脚本#!/bin/bashdockerrm-fmysql8dockerrun–namemysql8\-eMYSQL_ROOT_PASSWORD=123456\-v/usr/local/mysql/logs:/logs\-v/usr/local/mysql/data:/var/lib/mys

    2022年10月5日
    0
  • docker端口映射后访问不了_docker暴露多个端口

    docker端口映射后访问不了_docker暴露多个端口docker端口映射突然无效1、查看防火墙状态(systemctlstatusfirewalld),防火墙是关闭的[root@VM-0-15-centos~]#systemctlstatusfirewalld●firewalld.service-firewalld-dynamicfirewalldaemonLoaded:loaded(/usr/lib/systemd/system/firewalld.service;disabled;vendorp

    2022年10月18日
    0
  • Docker安装RabbitMQ教程「建议收藏」

    Docker安装RabbitMQ教程「建议收藏」本章教程介绍如何利用Docker快速搭建RabbitMQ环境。目录一、拉取镜像二、运行容器三、访问测试一、拉取镜像dockerpullrabbitmq:3.7.7-management二、运行容器dockerrun-d–namerabbitmq3.7.7-p5672:5672-p15672:15672-v`pwd`/data:/var/lib/rabbitmq–hostnamemyRabbit-eRABBITMQ_DEFAUL..

    2022年5月23日
    33
  • docker 离线安装_docker 离线安装

    docker 离线安装_docker 离线安装docker离线安装方法下载地址:https://download.docker.com/linux/static/stable/x86_64/参考文档:https://docs.docker.com/engine/install/binaries/机房设备无法访问互联网原因,需要进行离线安装K8S生态周报|Docker和containerd全版本漏洞公布,近期在Docker中发现了一个影响所有版本的安全漏洞CVE-2022-24769,该漏洞已经在Docker最新的版本v20

    2022年9月26日
    0

发表回复

您的邮箱地址不会被公开。 必填项已用 * 标注

关注全栈程序员社区公众号