Setting up Docker on Ubuntu



  1. Update the apt cache and install curl

 

sudo apt-get update -y

sudo apt install curl

 

  1. Setup proxy servers in ~/.bashrc

 

     export http_proxy=http://<proxy-server>:<port>

     export https_proxy=http://<proxy-server>:<port>

 

  1. Add GPG key

 

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

 

  1. Install Docker

 

sudo apt install docker.io

 

  1. Setup proxy (instructions from https://docs.docker.com/config/daemon/systemd/#httphttps-proxy)

 

  • Create a systemd drop-in directory for the docker service:

 

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

 

  • Create a file named /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

 

  [Service]

  Environment="HTTP_PROXY=http://<proxy-server>:<port>"

  Environment="HTTPS_PROXY=http://<proxy-server>:<port>"

 

  • Flush changes and restart Docker:

 

  sudo systemctl daemon-reload

  sudo systemctl restart docker

 

  • Verify

  sudo systemctl show --property=Environment docker

 

 

  1. For docker build, see https://dev.to/zyfa/setup-the-proxy-for-dockerfile-building--4jc8 for proxy settings. Two options:

                  docker build --build-arg http_proxy=http://<proxy-server>:<port>

        --build-arg https_proxy=http://<proxy-server>:<port> .

 

You also can set the proxy in the Dockerfile.


ENV http_proxy <proxy-server without http prefix>:<port>

 


Comments

Popular posts from this blog

QTreeView and QTableView dynamic changes

C++ strings and string_view