IT数码 购物 网址 头条 软件 日历 阅读 图书馆
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
图片批量下载器
↓批量下载图片,美女图库↓
图片自动播放器
↓图片自动播放器↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁
 
   -> 系统运维 -> docker(3) -> 正文阅读

[系统运维]docker(3)

下载centos系统镜像

[root@docker ~]# docker pull centos

使用镜像启动容器并进入容器

[root@docker ~]# docker run -it --name centos.nginx centos /bin/bash

安装epel源和nginx

[root@369372c88fd6 /]# yum install epel-release -y
[root@369372c88fd6 /]# yum install nginx -y

配置nginx为前台启动模式

在nginx的配置文件中加入如下参数

vi /etc/nginx/nginx.conf

daemon off;

查看容器

[root@docker ~]# docker ps -a
CONTAINER ID   IMAGE          COMMAND                  CREATED              STATUS                     PORTS     NAMES
369372c88fd6   centos         "/bin/bash"              About a minute ago   Exited (0) 3 seconds ago             centos.nginx
596d668963f3   nginx          "/docker-entrypoint.…"   2 hours ago          Up 2 hours                 80/tcp    b1
86bd7474d739   nginx          "/docker-entrypoint.…"   2 hours ago          Exited (0) 2 hours ago               eager_margulis
7d382d20bb59   ubuntu:15.10   "/bin/bash"              7 hours ago          Exited (127) 7 hours ago             recursing_visvesvaraya
5a11a555bbe8   ubuntu:15.10   "/bin/echo 'Hello wo…"   7 hours ago          Exited (0) 7 hours ago               epic_kilby

制作镜像

[root@docker ~]# docker commit -m "nginx" -a "centos-nginx" -c 'CMD ["/usr/sbin/nginx"]' 369372c88fd6 centos-nginx
sha256:7d17908e5897a0b87768fcad4e902018d030739b1b98c40834c81a80b95994e4

查看镜像

[root@docker ~]# docker images
REPOSITORY     TAG       IMAGE ID       CREATED         SIZE
centos-nginx   latest    7d17908e5897   9 seconds ago   345MB
ubuntu         latest    1318b700e415   39 hours ago    72.8MB
nginx          latest    08b152afcfae   6 days ago      133MB
httpd          latest    73b8cfec1155   6 days ago      138MB
<none>         <none>    65c9239c9300   3 weeks ago     1.24MB
busybox        latest    69593048aa3a   7 weeks ago     1.24MB
hello-world    latest    d1165f221234   4 months ago    13.3kB
centos         latest    300e315adb2f   7 months ago    209MB
ubuntu         15.10     9b9cb95443b5   5 years ago     137MB

使用新镜像启动容器

[root@docker ~]# docker run --name nginx -p 8888:80 -d centos-nginx
021ddfcec4c75f9adac1b79d95e207ffb8b6d6d802066915c11dcdb02230b90d
[root@docker ~]# ss -antl
State         Recv-Q         Send-Q                 Local Address:Port                 Peer Address:Port        Process        
LISTEN        0              128                          0.0.0.0:22                        0.0.0.0:*                          
LISTEN        0              128                          0.0.0.0:8888                      0.0.0.0:*                          
LISTEN        0              128                             [::]:22                           [::]:*                          
LISTEN        0              128                             [::]:8888                         [::]:*              

image-20210728204936421

[root@docker ~]# docker run --name centos-nginx -it centos
[root@70bfaf3d4b7a /]# mkdir data
[root@70bfaf3d4b7a /]# echo 'Busybox page test.' > data/index.html
[root@70bfaf3d4b7a /]# cat data/index.html 
Busybox page test.
[root@docker ~]# docker commit -p centos-nginx
sha256:2ed3d7464d74900c9960cecdce1ecad72903a500ed7f0171675118b89a76acee
[root@docker ~]# docker images
REPOSITORY     TAG       IMAGE ID       CREATED          SIZE
<none>         <none>    2ed3d7464d74   5 seconds ago    209MB
centos-nginx   latest    7d17908e5897   11 minutes ago   345MB
ubuntu         latest    1318b700e415   40 hours ago     72.8MB
nginx          latest    08b152afcfae   6 days ago       133MB
httpd          latest    73b8cfec1155   6 days ago       138MB
<none>         <none>    65c9239c9300   3 weeks ago      1.24MB
busybox        latest    69593048aa3a   7 weeks ago      1.24MB
hello-world    latest    d1165f221234   4 months ago     13.3kB
centos         latest    300e315adb2f   7 months ago     209MB
ubuntu         15.10     9b9cb95443b5   5 years ago      137MB
[root@docker ~]# docker tag 7d17908e5897 18463751776/centos-nginx:0.1
[root@docker ~]# docker images
REPOSITORY                  TAG       IMAGE ID       CREATED          SIZE
<none>                      <none>    2ed3d7464d74   10 minutes ago   209MB
18463751776/centos-nginx    0.1       7d17908e5897   21 minutes ago   345MB
centos-nginx/centos-nginx   0.1       7d17908e5897   21 minutes ago   345MB
centos-nginx                latest    7d17908e5897   21 minutes ago   345MB
ubuntu                      latest    1318b700e415   40 hours ago     72.8MB
nginx                       latest    08b152afcfae   6 days ago       133MB
httpd                       latest    73b8cfec1155   6 days ago       138MB
<none>                      <none>    65c9239c9300   3 weeks ago      1.24MB
busybox                     latest    69593048aa3a   7 weeks ago      1.24MB
hello-world                 latest    d1165f221234   4 months ago     13.3kB
centos                      latest    300e315adb2f   7 months ago     209MB
ubuntu                      15.10     9b9cb95443b5   5 years ago      137MB


登录上传

[root@docker ~]# docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: 18463751776
Password: 
WARNING! Your password will be stored unencrypted in /root/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded
[root@docker ~]# docker push centos-nginx/centos-nginx:0.1
The push refers to repository [docker.io/centos-nginx/centos-nginx]
44d45c8164a7: Preparing 
2653d992f4ef: Preparing 
denied: requested access to the resource is denied

image-20210728210934829

  系统运维 最新文章
配置小型公司网络WLAN基本业务(AC通过三层
如何在交付运维过程中建立风险底线意识,提
快速传输大文件,怎么通过网络传大文件给对
从游戏服务端角度分析移动同步(状态同步)
MySQL使用MyCat实现分库分表
如何用DWDM射频光纤技术实现200公里外的站点
国内顺畅下载k8s.gcr.io的镜像
自动化测试appium
ctfshow ssrf
Linux操作系统学习之实用指令(Centos7/8均
上一篇文章      下一篇文章      查看所有文章
加:2021-07-29 12:03:21  更:2021-07-29 12:05:47 
 
开发: C++知识库 Java知识库 JavaScript Python PHP知识库 人工智能 区块链 大数据 移动开发 嵌入式 开发工具 数据结构与算法 开发测试 游戏开发 网络协议 系统运维
教程: HTML教程 CSS教程 JavaScript教程 Go语言教程 JQuery教程 VUE教程 VUE3教程 Bootstrap教程 SQL数据库教程 C语言教程 C++教程 Java教程 Python教程 Python3教程 C#教程
数码: 电脑 笔记本 显卡 显示器 固态硬盘 硬盘 耳机 手机 iphone vivo oppo 小米 华为 单反 装机 图拉丁

360图书馆 购物 三丰科技 阅读网 日历 万年历 2024年5日历 -2024/5/2 11:21:45-

图片自动播放器
↓图片自动播放器↓
TxT小说阅读器
↓语音阅读,小说下载,古典文学↓
一键清除垃圾
↓轻轻一点,清除系统垃圾↓
图片批量下载器
↓批量下载图片,美女图库↓
  网站联系: qq:121756557 email:121756557@qq.com  IT数码