Centos Dockerfile Example

2/12/2022by admin
  1. Centos 7 Dockerfile Example
  2. Centos Dockerfile Example Online
  3. Centos Dockerfile Example
  4. Centos Dockerfile Example Code

Browse The Most Popular 7 Docker Dockerfile Ansible Junos Open Source Projects. This is a Linux Docker image based on ekidd/rust-musl-builder but using debian:buster-slim. It contains essential tools for compile Rust projects such as Linux static binaries via musl-libc / musl-gcc ( x8664-unknown-linux-musl ) and macOS binaries ( x8664-apple-darwin ) via osxcross just using the same Linux image.

  • Install / Initial Config
  • NTP / SSH Server
  • DNS / DHCP Server
  • Storage Server
  • Virtualization
  • Container Platform
  • Cloud Compute
  • Directory Server
  • Web Server
  • Database
  • FTP / Samba / Mail
  • Proxy / Load Balance
  • Monitoring
  • Security
  • Lang / Development
  • Desktop / Others
  • Others #2
    • Bacula - Backup
    • Memcached - Memory Cache
    • RabbitMQ - Message Broker
    • ElasticStack - Search Engine++
    • Subversion - Revision Control
    • Git - Revision Control
    • Ansible - Config Manage
    • PXE Boot- PXE Server
    • Pacemaker - HA Cluster
    • OpenVPN - VPN Server
    • WireGuard - VPN Server
    • NextCloud - Cloud Storage
    • LVM - LVM Manage

1. Introduction
Docker is an open source application container engine based on the go language. It can package the developer's application and dependent packages into a portable container, and then publish it to any popular Linux machine, which can greatly reduce the number of developers The workload of Docker can also be virtualized.
2. Docker installation
Docker has become very popular since its release. At present, Linux systems, windows systems and mac systems all support docker. This article introduces the installation and simple use of Docker with Linux systems .
Docker has not been released for a long time, so Linux also has restrictions on Docker support, which only supports 64-bit. Currently centos7 already supports Docker. The installation requires a 64-bit system and a kernel version of 3.10 or higher. For centos6, the installation requires centos6. .5 or higher, the same system is 64-bit, docker only supports 64-bit, and the kernel version is 2.6.32-431 or higher.
You can use uname -a to query the kernel version. The kernel version of the
View Image
blogger is 3.10.0-862. For convenience, the centos7 system is installed. If it is centos6, the kernel version needs to be upgraded, which is a little troublesome.
Docker installation:
Docker has two There are two versions, Docker-ee and Docker-ce
Docker-ce is a community free version, Docker-ee is an enterprise version, which requires a fee. The installation in this article is the Docker-ce community free version
. Install the corresponding required package dependencies

View Image
downloads the yum source of docker-ce to/etc/yum.repos.d/

View Image
yum install docker-ce
View Image
docker installation is complete, start docker, check docker version information

View Image
Docker installed successfully.
3. Docker use.
run a hello-world container from the simplest hello-world. If there is no hello-world image locally, it will be automatically pulled from the remote docker hub

View Image
uses the docker images command to query the current image on the local host. There are a lot of other images on my machine. It is ok to see the hello-world image.

View Image
delete the image using the following command


Centos 7 Dockerfile Example

View Image
deleted successfully.
Pull the image from the remote docker hub

View Image to
view the list of local mirrors, and you can query the docker hub to pull the list of mirrors before successfully pulling the
View Image

first field of View Image is imagename (mirror name), and the fourth field is official, whether it is an official mirror or not. Individuals can also put the mirror they made on the docker hub and find the name of the mirror they want to download. got it.
Run a new container

Run a new container and call the print command

View Image
runs an interactive container (container)

View Image
can find that it has entered the container, exit and use exit or ctl+d to
pull a mirror image from the remote docker hub.
View Image
runs a new container in the background

View Image
View the details of the currently running container

View Image
View container port

View Image
can see that the port of container test1 is mapped to 32768 of the machine, and you can access port 32768 of the machine ip to view
View Image to
view container logs

View Image
stops specifying the container

Centos Dockerfile Example Online

View Image
can be used by running the container again

View Image
View the running process inside the specified container

View Image to
view historically launched containers

View Image
deletes the container, the container must be stopped

View Image
other commands
to add new tags to the image


Query container ip


Submit a copy of the container

I write so much first, and I will supplement it later
: I
mentioned that you can upload your own local mirror to the docker hub, so how to generate your own mirror? Docker provides a docker file method to generate a local mirror, you can also use Use docker file to package your project into a mirror image.
4. Dockerfile part of the command
1. the prefix of each instruction must be capitalized

The dockerfile command actually has a lot of functions similar to the linux system itself, and it is relatively easy to understand. To facilitate understanding, the blogger made an example of packaging nginx service into a mirror and using it.
First of all, we need to put the nginx installation package and dockerfile we need to use in the same directory.
View Image to
create a Dockerfile file. In fact, the nginx installation process is written into a script, but it must conform to the dockerfile specification.

View Image
build mirror operation

carried out

Centos Dockerfile Example

Please note that the final surface has a point '.' , Dockerfile specified path can also be written as absolute path
View Image
execute successfully will appear
View Image
View local mirror you can see that we build mirrored
View Image
run-time image we build, map Go to the local 80 port
View Image to
view the local port 80
View Image
access the local 80 port, and the View Image is successful

Centos dockerfile example online

Centos Dockerfile Example Code

Reprinted at: https://blog.51cto.com/13917261/2174203

Comments are closed.