Install and Use Docker on Ubuntu 22.04
Install and Use Docker on Ubuntu 22.04
Step 1 — Installing Docker
- First, update your system by running
1 | sudo apt update && sudo apt upgrade -y |
- Next, install a few prerequisite packages which let apt use packages over HTTPS:
1 | sudo apt install apt-transport-https ca-certificates curl software-properties-common |
- Then add the GPG key for the official Docker repository to your system:
1 | curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /usr/share/keyrings/docker-archive-keyring.gpg |
- Add the Docker repository to APT sources:
1 | echo "deb [arch=$(dpkg --print-architecture) 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 |
- Update your existing list of packages again for the addition to be recognized:
1 | sudo apt update |
- Make sure you are about to install from the Docker repo instead of the default Ubuntu repo:
1 | apt-cache policy docker-ce |
- Finally, install Docker:
1 | sudo apt install docker-ce |
- Docker should now be installed, the daemon started, and the process enabled to start on boot. Check that it’s running:
1 | sudo systemctl status docker |
Step 2 — Working with Docker Images
- To check whether you can access and download images from Docker Hub, type:
1 | docker run hello-world |
- You can search for images available on Docker Hub by using the docker command with the search subcommand. For example, to search for the Ubuntu image, type:
1 | docker search ubuntu |
- Execute the following command to download the official ubuntu image to your computer:
1 | docker pull ubuntu |
- To see the images that have been downloaded to your computer, type:
1 | docker images |
Step 3 — Running a Docker Container
評論
歡迎來到 GitHub 留言區
歡迎分享想法、問題或勘誤。登入 GitHub 後即可留言;支援 Markdown、Emoji 與外部圖片連結。
GitHub 登入MarkdownEmoji
使用 Disqus 參與討論
Disqus 是第三方服務,載入後可能使用 Cookie。可依 Disqus 設定使用 Facebook 等多元登入方式,也能加入圖片與 GIF;媒體功能需在 Disqus 後台開啟。
多元登入圖片 / GIF文章反應


