2020年8月31日星期一

Install Docker On Ubuntu

STEP1. For updating the OS of ubuntu
sudo apt update

STEP2.  Install a few prerequisite packages which let apt use packages over HTTPS:

sudo apt install apt-transport-https ca-certificates curl software-properties-common

STEP3. Add the GPG key for the official Docker repository to your system

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

STEP4. Add the Docker repository to APT sources:

sudo add-apt-repository "deb [arch=amd64] https://download.docker.com/linux/ubuntu bionic stable"

STEP5. Update the package database with the Docker packages from the newly added repo:

sudo apt update

STEP6. Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:

apt-cache policy docker-ce

STEP7. Finally, install Docker:

sudo apt install docker-ce

STEP8.Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:

sudo systemctl status docker

STEP9.  Avoid typing sudo whenever you run the docker command, add your username to the docker group:

sudo usermod -aG docker ${USER}

STEP10. To apply the new group membership, log out of the server and back in, or type the following:

su - ${USER}

STEP11. Confirm that your user is now added to the docker group by typing:

id

STEP12.If you need to add a user to the docker group that you’re not logged in as, declare that username explicitly using:

sudo usermod -aG docker ${USER}

STEP13. Start Docker Server.  

sudo service docker start

STEP14. Docker run helloworld  error and resolved method
~$ docker run helloworld
Unable to find image 'helloworld:latest' locally
docker: Error response from daemon: pull access denied for helloworld, repository does not exist or may require 'docker login': denied: requested access to the resource is denied.
See 'docker run --help'.
~$ docker login
Login with your Docker ID to push and pull images from Docker Hub. If you don't have a Docker ID, head over to https://hub.docker.com to create one.
Username: lqwangxg
Password:
WARNING! Your password will be stored unencrypted in /home/wangxg/.docker/config.json.
Configure a credential helper to remove this warning. See
https://docs.docker.com/engine/reference/commandline/login/#credentials-store

Login Succeeded


 

没有评论: