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 display TIF format images in browser

The browser displays TIF format images Copy code T...

How to set up scheduled backup tasks in Linux centos

Implementation Preparation # Need to back up the ...

JavaScript implements AI tic-tac-toe game through the maximum and minimum algorithm

Without further ado, let’s run the screenshot dir...

Detailed explanation of common commands in Docker repository

Log in docker login Complete the registration and...

How to use mysqldump for full and point-in-time backups

Mysqldump is used for logical backup in MySQL. Al...

Talk about the understanding of CSS attribute margin

1.What is margin? Margin is used to control the sp...

VMware Workstation is not compatible with Device/Credential Guard

When installing a virtual machine, a prompt appea...

8 Reasons Why You Should Use Xfce Desktop Environment for Linux

For several reasons (including curiosity), I star...

Play and save WeChat public account recording files (convert amr files to mp3)

Table of contents Audio transcoding tools princip...

The difference between VOLUME and docker -v in Dockerfile

There are obvious differences between volume moun...

MySql index detailed introduction and correct use method

MySql index detailed introduction and correct use...

Detailed explanation of Linux lsof command usage

lsof (list open files) is a tool to view files op...

Mysql dynamically updates the database script example explanation

The specific upgrade script is as follows: Dynami...

How to detect file system integrity based on AIDE in Linux

1. AIDE AIDE (Advanced Intrusion Detection Enviro...