Implementation of Docker packaging image and configuration modification

Implementation of Docker packaging image and configuration modification

I have encountered many problems in learning Docker and actual operation recently, so I wrote a blog to record them.

Install

I installed the Windows version Docker desktop, it is quite troublesome to use Docker on Windows, you need to configure some things, install Docker desktop on Windows.

After the installation is complete, you can usually run it as an administrator. If you encounter an error message "Docker Access Denied" and cannot open it, you need to add the current user of the computer to In the docker-users user group.

insert image description here

Open the command line tool and enter the following command to check whether Docker is installed successfully:

insert image description here

You can even run a hello-world:

insert image description here

Packaging image

We all know that the packaging command is docker build , in addition to this, requires a I won’t introduce the Dockerfile file or command line packaging, but I will share a vscode plug-in called Docker!

insert image description here

After installation, there will be a small whale in the sidebar, and we can see the status and image of the container, provided that Docker Desktop is successfully installed.

insert image description here

Then right-click on our Dockerfile file and click build image. You will be prompted to enter a name for the image, then press Enter.

insert image description here

Run the container and add environment variables

Sometimes the normal operation of the project depends on some environment variables, which we can The -e directive adds:

docker run -p 4000:4000 -e env1=xxxx -e env2=yyyy ImageID

Run the container and customize the container name

We run hello-world twice and then open docker desktop. We can see that the container name seems to be randomly assigned each time.

insert image description here

We can use –name specifies the name of the container:

docker run --name hello hello-world

Running results:

insert image description here

Docker modify host

When running a new container using docker run, pass the parameter –add-host to add the domain name and IP information to the container’s /etc/hosts file:

docker run -p 8080:8080 --add-host=hostname:127.0.0.1 ImageID

Export the image to local

After we develop and package the project into an image, we may need to deploy and test it for operation and maintenance or backend personnel. We can use The save -o command exports the image:

docker save -o .\saved path\image file name Image example:
dicker save -o .\Desktop\hello.tar hello-world

Personally, I think it would be more convenient to use docker hub!

This is the end of this article about Docker packaging images and configuration modification. For more relevant Docker packaging images and configuration content, please search for previous articles on 123WORDPRESS.COM or continue to browse the following related articles. I hope everyone will support 123WORDPRESS.COM in the future!

You may also be interested in:
  • Analysis of the Docker image construction principle (you can build an image without installing Docker)
  • Docker installation and configuration image acceleration implementation
  • Solution to the problem that the image name is none after Docker load
  • How to view image information in Docker
  • Use Docker to build a Git image using the clone repository
  • Solution to Docker image downloading too slowly

<<:  Beginners learn some HTML tags (3)

>>:  In-depth study of MySQL composite index

Recommend

How to use Docker Swarm to build WordPress

cause I once set up WordPress on Vultr, but for w...

MySQL database table partitioning considerations [recommended]

Table partitioning is different from database par...

Use of Linux xargs command

1. Function: xargs can convert the data separated...

Two ways to use react in React html

Basic Use <!DOCTYPE html> <html lang=&qu...

A brief discussion on browser compatibility issues in JavaScript

Browser compatibility is the most important part ...

Vuex implements simple shopping cart function

This article example shares the specific code of ...

Detailed tutorial on installing pxc cluster with docker

Table of contents Preface Preliminary preparation...

Detailed explanation of CSS counter related attributes learning

The CSS counter attribute is supported by almost ...

How to build a DHCP server in Linux

Table of contents 1. Basic knowledge: 2. DHCP ser...

Vue implements simple data two-way binding

This article example shares the specific code of ...

MySQL Failover Notes: Application-Aware Design Detailed Explanation

1. Introduction As we all know, in the applicatio...

MySQL 8.0.12 installation and configuration graphic tutorial

Recorded the download and installation tutorial o...