November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Docker Centos 7

nginx?HTTPS

vim  /etc/default/docker

OPTIONS=”–insecure-registry 192.168.1.9:5000″

docker-images     10.0.0.5     docker
10.0.0.6     docker

[root@docker-images ~]# cat /etc/RedHat-release
CentOS Linux release 7.2.1511 (Core)
[root@docker-images ~]# uname -r
3.10.0-327.el7.x86_64
[root@docker-images ~]# uname -m
x86_64
[root@docker-images ~]# uname -a
Linux docker-images 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@docker-images ~]#

1?selinux

[root@docker-images ~]# systemctl stop firewalld
[root@docker-images ~]# systemctl disable firewalld
[root@docker-images ~]# setenforce 0
[root@docker-images ~]# getenforce
Permissive
[root@docker-images ~]#

2?docker

yum install docker
[root@docker-images ~]# systemctl enable docker
[root@docker-images ~]# systemctl start docker

3?registry

[root@docker-images ~]# docker pull registry
[root@docker-images ~]# docker images
REPOSITORY          TAG                IMAGE ID            CREATED            SIZE
docker.io/registry  latest              047218491f8c        10 days ago        33.17 MB
[root@docker-images ~]#

4?Based on private warehouse mirroring to run containers

[root@docker-images ~]#  docker run -d -p 5000:5000 -v /opt/data/registry:/tmp/registry docker.io/registry
# The default repository is created in / tmp / registry and the repository location is specified with the -v parameter
1e8b1a03013ee66034b40aee1820000a2ccf026a3b1e43606f3e4007b2a9d455
[root@docker-images ~]#
[root@docker-images ~]# docker ps  #View the running container
CONTAINER ID        IMAGE                COMMAND                  CREATED            STATUS              PORTS                    NAMES
1e8b1a03013e        docker.io/registry  “/entrypoint.sh /etc/”  35 seconds ago      Up 32 seconds      0.0.0.0:5000->5000/tcp  goofy_mcnulty
[root@docker-images ~]#

5?access to private warehouses

[root@docker-images ~]# curl 127.0.0.1:5000/v2
<a href=”/v2/”>Moved Permanently</a>.
[root@docker-images ~]#
# Description registry deployment is successful

6?Mark the base image as a mirror

[root@docker-images ~]# docker search  docker.io/Fedora/ssh|grep docker.io/fedora/ssh
docker.io  docker.io/fedora/ssh                                                                        20                  [OK]
[root@docker-images ~]# docker pull docker.io/fedora/ssh    #Download the image
[root@docker-images ~]# docker images
REPOSITORY            TAG                IMAGE ID            CREATED            SIZE
docker.io/registry    latest              047218491f8c        10 days ago        33.17 MB
docker.io/fedora/ssh  latest              ad6a3ff29626        4 weeks ago        396.7 MB
[root@docker-images ~]# docker tag docker.io/fedora/ssh 127.0.0.1:5000/ssh    #Tagged
[root@docker-images ~]# docker images
REPOSITORY            TAG                IMAGE ID            CREATED            SIZE
docker.io/registry    latest              047218491f8c        10 days ago        33.17 MB
127.0.0.1:5000/ssh    latest              ad6a3ff29626        4 weeks ago        396.7 MB
docker.io/fedora/ssh  latest              ad6a3ff29626        4 weeks ago        396.7 MB
[root@docker-images ~]#
[root@docker-images ~]# vim /etc/sysconfig/docker
OPTIONS=”–selinux-enabled  –insecure-registry 10.0.0.5:5000″    #Customize the private warehouse URL
[root@docker-images ~]# systemctl restart docker

7???????????

[root@docker-images ~]# docker start 1e8  #Open the local library
1e8
[root@docker-images ~]# docker ps
CONTAINER ID        IMAGE                COMMAND                  CREATED            STATUS              PORTS                    NAMES
1e8b1a03013e        docker.io/registry  “/entrypoint.sh /etc/”  4 hours ago        Up 3 seconds        0.0.0.0:5000->5000/tcp  goofy_mcnulty
[root@docker-images ~]#
[root@docker-images ~]# docker push 127.0.0.1:5000/ssh    #Upload a library with a good label
The push refers to a repository [127.0.0.1:5000/ssh]
482d621bda33: Pushed
510f15c27a8b: Pushed
e4f86288aaf7: Pushed
latest: digest: sha256:5ad5aec14bb7aa63fdcea1772db6ab5b5de99b0a023d234e61f5aa8c9435e8ff size: 948
[root@docker-images ~]#

8, view has been uploaded a good mirror

[root@docker-images ~]# curl 10.0.0.5:5000/v2/_catalog
{“repositories”:[“ssh”]}
[root@docker-images ~]#

?????????????

http://10.0.0.5:5000/v2/_catalog

9?View the image that has been uploaded in the browser

[root@centos7 ~]# vim /etc/sysconfig/docker      #Add private warehouse address
OPTIONS=”–selinux-enabled  –insecure-registry 10.0.0.5:5000″

[root@centos7 ~]# systemctl restart docker
[root@centos7 ~]# docker pull 10.0.0.5:5000/ssh

You can see that you can download the mirror to prove that the private warehouse to create a success

[root@centos7 ~]# docker images
REPOSITORY          TAG                IMAGE ID            CREATED            SIZE
10.0.0.5:5000/ssh  latest              ad6a3ff29626        4 weeks ago        396.7 MB
[root@centos7 ~]#

Then run a centos7 container through your own private library

1?From another database to send a centos image pushed to the private library server

[root@docker-images ~]# ls
anaconda-ks.cfg  centos.tar
[root@docker-images ~]# docker load < centos.tar    # Import the image into the docker
34e7b85d83e4: Loading layer [==================================================>] 199.9 MB/199.9 MB
Loaded image: docker.io/centos:latest                                          ] 557.1 kB/199.9 MB
[root@docker-images ~]# docker images
REPOSITORY            TAG                IMAGE ID            CREATED            SIZE
docker.io/registry    latest              047218491f8c        10 days ago        33.17 MB
127.0.0.1:5000/ssh    latest              ad6a3ff29626        4 weeks ago        396.7 MB
docker.io/fedora/ssh  latest              ad6a3ff29626        4 weeks ago        396.7 MB
docker.io/centos      latest              67591570dd29        12 weeks ago        191.8 MB
[root@docker-images ~]#

2?Once again marked with their own label

[root@docker-images ~]# docker tag docker.io/centos:latest  10.0.0.5:5000/lcentos
# In order to distinguish the front, I will centos do other markup
[root@docker-images ~]# docker images
REPOSITORY              TAG                IMAGE ID            CREATED            SIZE
docker.io/registry      latest              047218491f8c        10 days ago        33.17 MB
127.0.0.1:5000/ssh      latest              ad6a3ff29626        4 weeks ago        396.7 MB
docker.io/fedora/ssh    latest              ad6a3ff29626        4 weeks ago        396.7 MB
docker.io/centos        latest              67591570dd29        12 weeks ago        191.8 MB
10.0.0.5:5000/lcentos  latest              67591570dd29        12 weeks ago        191.8 MB
[root@docker-images ~]#

3?Upload a good mirror to your own private library

[root@docker-images ~]# docker push 10.0.0.5:5000/lcentos

4?View the uploaded image

[root@docker-images ~]# curl http://10.0.0.5:5000/v2/_catalog
{“repositories”:[“lcentos”,”ssh”]}
[root@docker-images ~]#

Browser view

5?Once again to prepare the environment for the test machine above pull

[root@centos7 ~]# docker pull 10.0.0.5:5000/lcentos
[root@centos7 ~]# docker images
REPOSITORY              TAG                IMAGE ID            CREATED            SIZE
10.0.0.5:5000/ssh      latest              ad6a3ff29626        4 weeks ago        396.7 MB
10.0.0.5:5000/lcentos  latest              67591570dd29        12 weeks ago        191.8 MB
[root@centos7 ~]#

6?Create and run a container

[root@centos7 ~]# docker run -d -it –privileged=false -p 80:80 –name abccentos 10.0.0.5:5000/lcentos /bin/bash
15b9f42b3d63846085664139bff0c041f614bc2b717787686d23785d98b37160
[root@centos7 ~]# docker ps -a
CONTAINER ID        IMAGE                  COMMAND            CREATED            STATUS              PORTS                NAMES
15b9f42b3d63        10.0.0.5:5000/lcentos  “/bin/bash”        16 seconds ago      Up 13 seconds      0.0.0.0:80->80/tcp  abccentos
[root@centos7 ~]#

7?Into the container view, you can see the version of centos and other information

[root@centos7 ~]# docker attach 15b9f42b3d63
[root@15b9f42b3d63 /]# cat /etc/redhat-release
CentOS Linux release 7.3.1611 (Core)
[root@15b9f42b3d63 /]# uname -r
3.10.0-327.el7.x86_64
[root@15b9f42b3d63 /]# uname -a
Linux 15b9f42b3d63 3.10.0-327.el7.x86_64 #1 SMP Thu Nov 19 22:10:57 UTC 2015 x86_64 x86_64 x86_64 GNU/Linux
[root@15b9f42b3d63 /]#

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>