Container Restaurant(3) Docker 环境设置

Container Restaurant(3) Docker 环境设置

首页模拟经营Cat restaurant更新时间:2024-07-31

前两章我们介绍的容器的由来和实现容器化的一些底层技术,今天开始我们将正式开启我们Docker的学习之旅,工欲善其事必先利其器,正式开始之前我们先布置好接下来需要用到的环境。

Let's Go!

Docker有自己的商业版本,由于我只是个“路人”的缘故,我们所有的分享都只会以Docker的开源版本docker-ce为基础,系统发行版基于CentOS 7。

实验环境概述:

一个小提示:安装好环境之后,请自行创建虚拟机镜像,以便在后面的日子里玩坏了方便重新开始!!!

# 虚拟机资源: 2 core 4GB 单网卡NAT模式 # 操作系统: [root@docker ~]# cat /etc/redhat-release CentOS Linux release 7.8.2003 (Core) # 内核版本: [root@docker ~]# uname -r 3.10.0-1127.13.1.el7.x86_64 DOCKER安装

首先需要安装yum仓库管理工具,用以添加docker官方yum源:

[root@docker ~]# yum install -y yum-utils # 添加docker yum源 [root@docker ~]# yum-config-manager \ --add-repo \ https://download.docker.com/linux/centos/docker-ce.repo # 安装docker [root@docker ~]# yum install docker-ce docker-ce-cli containerd.io [root@docker ~]# systemctl start docker [root@docker ~]# systemctl enable docker

docker使用/etc/docker/daemon.json为其守护进程dockerd提供相关的启动参数。

奔跑吧,docker

计算机世界的万物初始之地--helloWorld

[root@docker ~]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Downloading [========> ] 423B/2.529kB

我们满怀希望,但由于“众所周知的问题”,我在这里卡了超过一顿饭的时间。

如何加速DockerHub上的镜像源?先用你的支付宝打开阿里云,进入控制台选择“容器镜像服务”-->“镜像服务中心”-->“镜像加速器”,你将获得免费的容器加速指引,就如上面提到的你将配置/etc/docker/daemon.json,以实现为dockerd守护进程设置相关参数

加速器配置,重新运行尝试启动Hello World,从此体验“飞一般的感觉”。

[root@docker ~]# cat /etc/docker/daemon.json { "registry-mirrors": ["https://tlwy9ltd.mirror.aliyuncs.com"] } [root@docker ~]# docker run hello-world Unable to find image 'hello-world:latest' locally latest: Pulling from library/hello-world 0e03bdcc26d7: Pull complete Digest: sha256:49a1c8800c94df04e9658809b006fd8a686cab8028d33cfba2cc049724254202 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/

查看全文
大家还看了
也许喜欢
更多游戏

Copyright © 2024 妖气游戏网 www.17u1u.com All Rights Reserved