docker

1.创建虚拟机,20G硬盘,2或者4G内存,2x2的CPU,网卡NAT模式
先配置网络,IP:192.168.200.30

[root@localhost ~]# cat /etc/sysconfig/network-scripts/ifcfg-ens33

TYPE="Ethernet"
PROXY_METHOD="none"
BROWSER_ONLY="no"
BOOTPROTO="static"
DEFROUTE="yes"
IPV4_FAILURE_FATAL="no"
IPV6INIT="yes"
IPV6_AUTOCONF="yes"
IPV6_DEFROUTE="yes"
IPV6_FAILURE_FATAL="no"
IPV6_ADDR_GEN_MODE="stable-privacy"
NAME="ens33"
UUID="b3e9c321-b0c7-46ce-8947-f8b8a293da8a"
DEVICE="ens33"
ONBOOT="yes"
IPADDR=192.168.200.30
GATEWAY=192.168.200.2
NETMASK=255.255.255.0
DNS1=114.114.114.114

2.将提供的压缩包 Docker.tar.gz 上传至/root 目录并解压。 centos通过光盘挂载
[root@localhost ~]# tar -zxvf Docker.tar.gz

配置本地 YUM 源,没有目录mkdir
[root@localhost ~]# mkdir -p /opt/centos
[root@localhost ~]# mount /dev/cdrom /opt/centos
修改配置文件
[root@localhost ~]# mv /etc/yum.repos.d/* /media/
[root@localhost ~]# vi /etc/yum.repos.d/local.repo

[centos]
name=centos
baseurl=file:///opt/centos
gpgcheck=0
enabled=1
[kubernetes]
name=kubernetes
baseurl=file:///root/Docker
gpgcheck=0
enabled=1

3.升级系统内核
yum upgrade -y
[root@localhost ~]# uname -r
3.10.0-862.el7.x86_64
[root@localhost ~]# systemctl stop firewalld
[root@localhost ~]# systemctl disable firewalld

Removed symlink /etc/systemd/system/multi-user.target.wants/firewalld.service.
Removed symlink /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.

[root@localhost ~]# iptables -t filter -F
[root@localhost ~]# iptables -t filter -X
[root@localhost ~]# iptables -t filter -Z
[root@localhost ~]# /usr/sbin/iptables-save

# Generated by iptables-save v1.4.21 on Fri May 10 20:23:31 2024
*filter
:INPUT ACCEPT [71:4716]
:FORWARD ACCEPT [0:0]
:OUTPUT ACCEPT [39:3540]
COMMIT
# Completed on Fri May 10 20:23:31 2024

[root@localhost ~]# sed -i ‘s/SELINUX=enforcing/SELINUX=disabled/g’ /etc/selinux/config

Last login: Fri May 10 17:53:07 2024 from 192.168.200.1
[root@localhost ~]# cat >> /etc/sysctl.conf << EOF

> net.ipv4.ip_forward=1
> net.bridge.bridge-nf-call-ip6tables=1
> net.bridge.bridge-nf-call-iptables=1
> EOF

[root@master~]# modprobe br_netfilter
[root@master ~]# sysctl -p

net.ipv4.ip_forward = 1
net.bridge.bridge-nf-call-ip6tables = 1
net.bridge.bridge-nf-call-iptables = 1

4.开始安装docker
[root@localhostr ~]# yum install -y yum-utils device-mapper-persistent-data
[root@localhost ~]# yum install docker-ce-18.09.6 docker-ce-cli-18.09.6 containerd.io-y
[root@localhostr ~]# systemctl daemon-reload
[root@localhost ~]# systemctl restart docker
[root@localhost ~]# systemctl enable docker

Created symlink from /etc/systemd/system/multi-user.target.wants/docker.service to /usr/lib/systemd/system/docker.service.

[root@localhost ~]# docker info

Containers: 0
 Running: 0
 Paused: 0
 Stopped: 0
Images: 0
Server Version: 18.09.6
Storage Driver: overlay2
 Backing Filesystem: xfs
 Supports d_type: true
 Native Overlay Diff: true
Logging Driver: json-file
Cgroup Driver: cgroupfs
Plugins:
 Volume: local
 Network: bridge host macvlan null overlay
 Log: awslogs fluentd gcplogs gelf journald json-file local logentries splunk syslog
Swarm: inactive
Runtimes: runc
Default Runtime: runc
Init Binary: docker-init
containerd version: b34a5c8af56e510852c35414db4c1f4fa6172339
runc version: 3e425f80a8c931f88e6d94a8c831b9d5aa481657
init version: fec3683
Security Options:
 seccomp
  Profile: default
Kernel Version: 3.10.0-862.el7.x86_64
Operating System: CentOS Linux 7 (Core)
OSType: linux
Architecture: x86_64
CPUs: 4
Total Memory: 1.779GiB
Name: master
ID: 6ZKT:BWIF:MBJL:XSSX:H2CT:JFV7:CHCW:G7LR:6HCF:ML2R:2BH2:HPJZ
Docker Root Dir: /var/lib/docker
Debug Mode (client): false
Debug Mode (server): false
Registry: https://index.docker.io/v1/
Labels:
Experimental: false
Insecure Registries:
 127.0.0.0/8
Live Restore Enabled: false
Product License: Community Engine

5.
[root@localhost ~]# ./image.sh
[root@localhost ~]# docker run -d -v /opt/registry:/var/lib/registry -p 5000:5000 --restart=always --name registry registry:latest 下面这排数字自动出现1ce68b8a0bdec1465e6e75b88e19e65d20609455baaa9d45b8d93c9fdca9b24e
[root@master ~]# docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
e1033e272201 registry:latest "/entrypoint.sh /etc鈥 3 minutes ago Up 3 minutes 0.0.0.0:5000->5000/tcp registry
浏览器输入http://192.168.200.30:5000/v2/
在这里插入图片描述

[root@localhost~]# vi /etc/docker/daemon.json

{


"insecure-registries":["192.168.200.30:5000"]

}

[root@localhost ~]# systemctl restart docker
标记
[root@localhost ~]# docker tag centos:latest 192.168.200.30:5000/centos:latest
6.上传镜像
[root@localhost ~]# docker push 192.168.200.30:5000/centos:latest
The push refers to repository [192.168.200.30:5000/centos]
9e607bb861a7: Pushed
latest: digest: sha256:6ab380c5a5acf71c1b6660d645d2cd79cc8ce91b38e0352cbf9561e050427baf size: 529
查看仓库的镜像
[root@localhost ~]# curl -L http://192.168.200.30:5000/v2/_catalog
{“repositories”:[“centos”]}
浏览器输入:http://192.168.200.30:5000/v2/_catalog
在这里插入图片描述

查看镜像
[root@localhost ~]# docker images

REPOSITORY                   TAG                 IMAGE ID            CREATED             SIZE
httpd                        latest              d3017f59d5e2        4 years ago         165MB
busybox                      latest              020584afccce        4 years ago         1.22MB
nginx                        latest              540a289bab6c        4 years ago         126MB
redis                        alpine              6f63d037b592        4 years ago         29.3MB
python                       3.7-alpine          b11d2a09763f        4 years ago         98.8MB
<none>                       <none>              4cda95efb0e4        4 years ago         80.6MB
192.168.200.30:5000/centos   latest              0f3e07c0138f        4 years ago         220MB
centos                       latest              0f3e07c0138f        4 years ago         220MB
registry                     latest              f32a97de94e1        5 years ago         25.8MB
swarm                        latest              ff454b4a0e84        5 years ago         12.7MB
httpd                        2.2.32              c51e86ea30d1        6 years ago         171MB
httpd                        2.2.31              c8a7fb36e3ab        7 years ag

7.运行容器
[root@localhost ~]# docker run -it --rm -d -p 80:80 nginx:latest
下面自动出现数字
ba696f72e257ecd4702d76246b42bae8f979ff11c892125c73211d2ab576537c
http://192.168.200.30
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值