Docker installation and use

Docker

Install Docker

Uninstall old version

sudo apt-get remove docker docker-engine docker.io containerd runc

Installing using a repository

Before installing Docker engine community on the new host for the first time, you need to set up the Docker repository. After that, you can install and update Docker from the repository.

Set up repository and update apt package index

   sudo apt-get update

Install the package to allow apt to use the repository over HTTPS

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

Add the official GPG key of Docker

 curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88

Verify that you now have the key with the fingerprint by searching the last 8 characters of the fingerprint

sudo apt-key fingerprint 0EBFCD88

pub rsa4096 2017-02-22 [SCEA]
9DC8 5822 9FC7 DD38 854A E2D8 8D81 803C 0EBF CD88
uid [ unknown] Docker Release (CE deb) docker@docker.com
sub rsa4096 2017-02-22 [S]

Use the following command to set up a stable repository

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) \
   stable"

   sudo apt-get update

   sudo apt-get install docker-ce docker-ce-cli containerd.io

Verify that docker engine community is installed correctly by running the Hello world image.

sudo docker run hello-world

Docker domestic image acceleration

Create or modify the / etc/docker/daemon.json file as follows

{
  "registry-mirrors": [
    "https://docker.mirrors.ustc.edu.cn",
    "https://registry.docker-cn.com",
    "http://hub-mirror.c.163.com"
  ]
}
  • Official image of Docker China

    https://registry.docker-cn.com

  • Netease

    http://hub-mirror.c.163.com

  • China University of science and technology

    https://docker.mirrors.ustc.edu.cn

  • Alicloud: to register

    https://cr.console.aliyun.com/

Image use

gitlab source code management

sudo docker run --detach \
  --hostname 192.168.2.11 \
  --publish 443:443 --publish 8055:80 --publish 10025:22 \
  --name gitlab \
  --restart always \
  --volume /media/anzhenghe/doc/DockerDir/gitlab/config:/etc/gitlab \
  --volume /media/anzhenghe/doc/DockerDir/gitlab/logs:/var/log/gitlab \
  --volume /media/anzhenghe/doc/DockerDir/gitlab/data:/var/opt/gitlab \
  gitlab/gitlab-ce:latest

odoo ERP CRM enterprise application

Start the PostgreSQL server

sudo docker run -d -e POSTGRES_USER=odoo -e POSTGRES_PASSWORD=odoo -e POSTGRES_DB=postgres --name odoo-db postgres:10

Start an Odoo instance

 sudo docker run -p 8069:8069 --name odoo --link odoo-db:db -t odoo

thingsboard IOT platform

sudo docker run -it -p 9090:9090 -p 1883:1883 -p 5683:5683/udp -v /media/anzhenghe/doc/DockerDir/thingsboard/mytb-data:/data -v /media/anzhenghe/doc/DockerDir/thingsboard/mytb-logs:/var/logs/thingsboard --name mytb --restart always thingsboard/tb-postgres

docker run - runs the container
-it - connects the terminal session to the output of the current ThingsBoard process
-p 9090:9090 - connect the local port 9090 to the exposed internal HTTP port 9090
-p 1883:1883 - connect the local port 1883 to the exposed internal MQTT port 1883
-p 5683:5683 - connect the local port 5683 to the exposed internal COAP port 5683
-V ~ /. Mytb data: / data - mount the directory of the host to the ThingsBoard DataBase data directory
-V ~ /. Mytb logs: / var / log / ThingsBoard - mount the directory of the host to the ThingsBoard log directory
– name mytb - friendly local name of the machine
– restart always - automatically restart ThingsBoard in case of system restart and ThingsBoard in case of failure.
thingsboard/tb Postgres - Porter image, which can also be thingsboard/tb Cassandra or thingsboard/tb

Default user name and password

typeuser namemailboxpassword
SystenAdministratorsysadmin@thingsboard.orgsysadmin
TenantAdministratortenant@thingsboard.orgtenant
CustomerUsercustomer@thingsboard.orgcustomer

Internet of things platform WEB Android apple

sudo docker run -p 8085:8085 -p 9443:9443 mpherg/blynk-server

Blynk Server 0.41.10 successfully started.
All server output is stored in folder '/data/logs' file.
Your Admin url is https://172.17.0.5:9443/admin
Your Admin login email is admin@blynk.cc
Your Admin password is admin
When deploying the project server, the Docker container will be set to start automatically to cope with the impact of power failure on the access of normal web projects. When using docker run to start the container, use the – restart parameter to set:

# docker run -m 512m --memory-swap 1G -it -p 58080:8080 --restart=always 
--name bvrfis --volumes-from logdata mytomcat:4.0 /root/run.sh

– restart specific parameter value details:
no - do not restart the container when the container exits;
On failure - the container is restarted only when exiting in a non-0 state;
always - restart the container regardless of the exit status;
You can also specify the maximum number of times Docker will attempt to restart the container when using the on - failure policy. By default, Docker will attempt to restart the container forever.

# sudo docker run --restart=on-failure:10 redis

If -- restart=always is not specified during creation, you can use the update command
docker update --restart=always xxx

The c9 ide may not be official

sudo docker run -it -d -p 80:80 \
-v /workspace/:/Docker/Cloud9/workspace/ kdelfour/cloud9-docker

Nextcloud network disk

gogs git server

Keywords: Operation & Maintenance Docker Container

Added by dgudema on Mon, 25 Oct 2021 05:30:39 +0300