Skip to content

Instantly share code, notes, and snippets.

@x86128
Last active June 16, 2021 15:36
Show Gist options
  • Save x86128/9e59eb45f5f5de5ca1b300e7e90b8394 to your computer and use it in GitHub Desktop.
Save x86128/9e59eb45f5f5de5ca1b300e7e90b8394 to your computer and use it in GitHub Desktop.
Install docker-ce on Ubuntu 20.04 LTS (focal)
FROM python:3.9-alpine
RUN mkdir /app
COPY sputnik.py /app/
WORKDIR /app
CMD python3 sputnik.py

Uninstall old legacy docker

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

fetch keys

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg

echo   "deb [arch=amd64 signed-by=/usr/share/keyrings/docker-archive-keyring.gpg] https://download.docker.com/linux/ubuntu \
   $(lsb_release -cs) stable" | sudo tee /etc/apt/sources.list.d/docker.list > /dev/null

sudo apt-get update

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

check docker daemon status

systemctl status docker.service

● docker.service - Docker Application Container Engine
     Loaded: loaded (/lib/systemd/system/docker.service; enabled; vendor preset>
     Active: active (running) since Mon 2021-06-14 14:31:07 +07; 6h ago
TriggeredBy: ● docker.socket
       Docs: https://docs.docker.com
   Main PID: 877 (dockerd)
      Tasks: 10
     Memory: 135.4M
     CGroup: /system.slice/docker.service
             └─877 /usr/bin/dockerd -H fd:// --containerd=/run/containerd/conta>

test

sudo docker run hello-world

Unable to find image 'hello-world:latest' locally
latest: Pulling from library/hello-world
b8dfde127a29: Pull complete 
Digest: sha256:9f6ad537c5132bcce57f7a0a20e317228d382c3cd61edae14650eec68b2b345c
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

To generate this message, Docker took the following steps:
 1. The Docker client contacted the Docker daemon.
 2. The Docker daemon pulled the "hello-world" image from the Docker Hub.
    (amd64)
 3. The Docker daemon created a new container from that image which runs the
    executable that produces the output you are currently reading.
 4. The Docker daemon streamed that output to the Docker client, which sent it
    to your terminal.

To try something more ambitious, you can run an Ubuntu container with:
 $ docker run -it ubuntu bash

Share images, automate workflows, and more with a free Docker ID:
 https://hub.docker.com/

For more examples and ideas, visit:
 https://docs.docker.com/get-started/

add $USER to docker group to run docker from regular user

sudo usermod -aG docker $USER

if you behind firewall

sudo mkdir -p /etc/systemd/system/docker.service.d

/etc/systemd/system/docker.service.d/http-proxy.conf

add this:

[Service]
Environment="HTTP_PROXY=http://proxy.example.com:80"
Environment="HTTPS_PROXY=https://proxy.example.com:443"
Environment="NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

reload docker & systemd

sudo systemctl daemon-reload
sudo systemctl restart docker
import sys
import time
seq = 0
while True:
sys.stdout.write(f"Системы стабильны: {seq}\n")
sys.stdout.flush()
seq += 1
if seq % 10 == 0:
sys.stderr.write("Корректировка орбиты завешена\n")
sys.stderr.flush()
time.sleep(2)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment