Docker series docker desktop installation using & running redis container

Posted by SyWill on Fri, 11 Feb 2022 20:48:18 +0100

Docker is a very popular container application at present. It can be deployed conveniently by using docker. This paper introduces the installation and use of docker to intuitively feel docker.

1. docker download installation

The official docker documentation gives detailed installation steps with reference address: https://docs.docker.com/get-docker/

The docker itself is an application that supports running on different operating systems, depending on your specific usage:

Note that compared to linux systems, docker for mac and windows provides Desktop in addition to Server, which is a desktop application even after installing docker under mac and window, but under linux there is only the server part.

I was playing with the mac, so download the MAC version:

Note that there are chips which are intel or apple chips, and my chips are intel chips. Then there are system version and memory requirements, mac requirements of more than 10.14, memory of more than 4,000; linux requires centos7.0 or more, see the official documents.
Then click Download the dmg file and install it, just like any other application.

2. Using docker Desktop

1. Home Interface
The docker Desktop main interface after startup,

  • Containers/Apps: Running container applications; This is empty at first, and we will start a redis container test later.
  • images: View mirror files, both local and remote;

Then execute the command in the mac command line window to view the version:

docker --version
## output
Docker version 20.10.6, build 370c289

2. Set up the interface
Click the Setup button to enter the setup interface:

  • General: Set up automatic updates, turn on self-starting docker Desktop, etc.
  • Resources: Set up hardware resources such as cpu, memory, etc.
  • Docker: set the docker engine parameter;
  • k8s related settings

3. Uninstall:
If you need to uninstall, just click Troubleshoot and select the Uninstall button below.

3. Test Startup redis Container

Start a redis container to feel the docker workflow.

3.1 Start the redis container

## Execute the following command
# -p 6379:6379: Map container port 6379 to host port 6379
# redis-server --appendonly yes: Execute the redis-server startup command in the container and open the redis persistence configuration
docker run -p 6379:6379 -d redis:latest redis-server 

## output
Unable to find image 'redis:latest' locally
latest: Pulling from library/redis
69692152171a: Pull complete 
a4a46f2fd7e0: Pull complete 
bcdf6fddc3bd: Pull complete 
b7e9b50900cc: Pull complete 
5f3030c50d85: Pull complete 
63dae8e0776c: Pull complete 
Digest: sha256:365eddf64356169aa0cbfbeaf928eb80762de3cc364402e7653532bcec912973
Status: Downloaded newer image for redis:latest
73f433b124438e292f65cef631c8d283c65c02d5971ecc3a481fcbf7b6998ca2

Explain:
After executing the command to run the redis mirror, docker first goes to the local repository to find the redis mirror. Since this is the first time we have started, there must not be a local one.
The docker then starts pull ing the mirror file from the remote repository, and the download version is the latest version because we were running without specifying a version.

3.2 Manage containers on desktop

Above we started the redis container, which you can see on docker desktop (restart if you don't see it)

There are buttons on the right to control the container stopping, running, etc.

Then mirror the list of files:

3.3 Command Verification:

Next we validate using the mac command terminal.

View Running Containers

#View containers running
docker ps

#output
CONTAINER ID   IMAGE          COMMAND                  CREATED          STATUS          PORTS                                       NAMES
27b58e03fb16   redis:latest   "docker-entrypoint.s..."   51 seconds ago   Up 50 seconds   0.0.0.0:6379->6379/tcp, :::6379->6379/tcp   adoring_margulis
c950107d7808   redis          "docker-entrypoint.s..."   2 minutes ago    Up 2 minutes    6379/tcp                                    upbeat_euler
0c4590c4bdda   redis:latest   "docker-entrypoint.s..."   5 minutes ago    Up 5 minutes    6379/tcp                                    mystifying_bassi
73f433b12443   redis          "docker-entrypoint.s..."   31 minutes ago   Up 7 minutes    6379/tcp                                    busy_cerf

Since I started multiple redis containers, docker ps can view all running containers.

Connect into redis container

docker exec -it adoring_margulis bash
#output
root@27b58e03fb16:/data# 

Where adoring_margulis is the name of the container, as you can see in the list above;

Connect redis
At this point, the operation of redis after installing redis on Linux is the same as when we normally install redis on linux, because now we enter the redis container, which is equivalent to entering a Linux system.

# Connect redis, mac with redis-cli command client
root@27b58e03fb16:/data# redis-cli
# set two keys and query all keys
127.0.0.1:6379> keys *
1) "name1"
2) "name"

This indicates that the redis container we are running with docker is functioning normally.

4. Configure Ali Mirror

After Docker installation, the default warehouse address is docker hub. https://www.docker.com/products/docker-hub ), pull or push mirror files, network speed may be unstable, in China, Ali cloud mirroring is generally recommended.
Reference resources Rookie Bird Tutorial:

Register Ali Yun Mirror Account

Ali Cloud Mirror Acquire Address: https://cr.console.aliyun.com/cn-hangzhou/instances/mirrors After registering for login, you can see your exclusive address by selecting Mirror Accelerator in the left menu:


Then add the configuration in the dockerdesktop as follows:

Then restart the docker and run the following command. If you see your own Ali cloud mirror address, it works:

$ docker info
Registry Mirrors:
    https://Your Ali Cloud Mirror Address

Topics: Docker