docker and docker-compose installation and configuration (windows+linux)

Installation of docker and docker-compose (2023.3.21 latest version)
docker official website: docker


1. Windows installation

(1) docker main body installation

1. Download

insert image description hereIf the download is too slow, I uploaded it to the network disk: docker win version

2. Install

Note: It may be necessary to enable virtualization, and enable it in the bios (usually enabled by default, if the prompt is not enabled, just enable it in the bios). The wsl in the
option is a linux subsystem based on windows. The minimum win10 1903 version can be unchecked If you choose, then you need to open the hyper-V virtual machine of windows.

insert image description here
If you use hyper-v, if you are prompted to restart after the installation is complete, just restart.
If you check to use wsl, the upgrade as shown below may appear (skip if not):
insert image description here
run powershell, upgrade, use the command

wsl -update

insert image description here
Just wait for the installation to complete, usually without rebooting.

3. Simple description of the operation interface

Graphical interface, you can do some settings, such as mirror image storage location, adjust it in the settings, so I won’t go into details here.
It is recommended to use cmd or powershell to operate, not in the graphical interface, and the rest is the same as in the linux command line.
insert image description hereinsert image description here

(2) docker-compose installation

1. Download docker-compose

docker-compose:docker-compose

Find and download: docker-compose-windows-x86_64.exe

2. Program running

It can only be run in the form of cmd, and double-clicking is invalid.
Put the downloaded exe file in the d:/docker directory, and rename it to docker-compose.exe.
You can remove the .exe when renaming, and the program can still run, so that it is the same as The commands of linux are the same, and the .exe is reserved here, so that you know that you are using windows
to run cmd, enter d:/docker, and run docker-compose.exe --version
Note: the command line operation under windows is slightly different from that of linux , to enter the drive letter, you must first enter the drive letter, and you cannot directly complete it in one step.

d:
cd d:/docker
docker-compose.exe --version

As shown in the figure below:
(Note: The directory of windows supports \ and / two ways of writing. In order to maintain the consistent habit with other unix-like systems, / is used here)
insert image description here

Two, linux installation

(1) docker main body installation

1. Recommend an installation script

curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun

2. Modify source - speed up access

New configuration file

vi /etc/docker/daemon.json

Plus commonly used sources, in no particular order

{
    "registry-mirrors" : [
    "https://registry.docker-cn.com",
    "https://docker.mirrors.ustc.edu.cn",
    "http://hub-mirror.c.163.com",
    "https://cr.console.aliyun.com",
    "https://mirror.ccs.tencentyun.com"
  ]
}

It will take effect after restarting docker

systemctl restart docker

(2) docker-compose installation

1. Download the program

docker-compose official website: docker-compose
is stored in the /usr/local/bin directory, so there is no need to modify the environment variables

cd /usr/local/bin

If the direct download is too slow, it is recommended to use other methods to download and upload

wget https://github.com/docker/compose/releases/download/v2.16.0/docker-compose-linux-x86_64

2. Adjust permissions

Modify the package name

mv /usr/local/bin/docker-compose-linux-x86_64 /usr/local/bin/docker-compose

Granted permission

chmod +x /usr/local/bin/docker-compose

3. Test

Enter the following command

docker-compose --version

If the software version is returned, the installation is normal

3. Other associations

Link: Deploy harbor yourself

Link: create your own mirror

Guess you like

Origin blog.csdn.net/ziqibit/article/details/129698618