Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Make a docker image

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Basic environment description

# cat / etc/redhat-releaseCentOS release 6.8 (Final)

Set docker image source #

# yum install-y yum-priorities & & rpm- ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm & & rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6

Install docker-io and febootstrap to make centos image and generate centos image #

# yum install docker-io-y # install docker# service docker start # launch docker# yum install febootstrap # create Image tool

Make CentOS image file centos6-image directory #

# febootstrap-I bash-I wget-I yum-I iputils-I iproute-I man-I vim-I openssh-server-I openssh-clients-I tar-I gzip centos6 centos6-image http://mirrors.aliyun.com/centos/6/os/x86_64/

-I: installed software package

Centos6: system version

Centos6-image: generated directory name

You can also make a mirror image of CentOS7 and change the address to the address of CentOS7, for example

# febootstrap-I bash-I net-tools-I wget-I yum-I iputils-I iproute-I man-I vim-I openssh-server-I openssh-clients-I tar-I gzip centos7 centos7-image https://mirrors.aliyun.com/centos/7/os/x86_64/

When setting ssh to enter the image, go directly to the root directory (if you do not do this step, you will directly enter the / directory)

# cd centos6-image & & cp etc/skel/.bash* root/

Generate basic image base#

# cd centos6-image & & tar-c. | | docker import-centos6-base |

View Mirror

# docker images

Create docker image of http based on basic image #

# cat DockerfileFROM centos6-base # means to create a MAINTAINER bamboo based on this image # represents the information of the image maker RUN yum install-y yum-priorities & & rpm- ivh http://dl.fedoraproject.org/pub/epel/6/x86_64/Packages/e/epel-release-6-8.noarch.rpm & & rpm--import / etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-6RUN yum install tar gzip vim wget httpd httpd-* -yRUN sed-I 's/#ServerName www.example.com:80/ServerName www.example.com:80/' / etc/httpd/conf/httpd.confEXPOSE 80 # indicates the open port number CMD ["/ usr/sbin/httpd" "- D", "FOREGROUND"] # indicates that a Dockerfile can only write one CMD command when the mirror is started. Multiple CMD executes the last # ENTRYPOINT ["/ usr/sbin/httpd", "- D", "FOREGROUND"] # in the same way as CMD

Build Image #

# cd centos6-image & & docker build-t centos6-httpd / root/bamboo-t is followed by the name of the image to be generated, that is, the above centos6-httpd followed by the directory of Dockerfile, which is the directory

View and test #

# docker images # View the newly generated image centos6-httpd# docker-d-name http-p 800 centos6-http# docker ps 80 centos6-http# docker ps-a # you can see the running image and port mapping # visit curl http://ip:800 to see the default welcome page of http

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report