linux環境安裝docker和dockercompose 命令頁錶快速完成

此文目的, 
  1. 如果你熟悉docker, 就沒必要每次都去一個一個命令開始複製 粘貼 執行 浪費時間.  直接把整理好的所有命令放入一次執行即可.
  2. 如果你是小白, 需要直接搭建環境成功,看到直觀效果, 這裏就可以. 可以增長信息,提升學習興趣. 不至於浪費時間太多,熱情冷卻.

docker快速直接執行:

#Uninstall old versions
O#lder versions of Docker were called docker or docker-engine. If these are installed, uninstall them, along with associated 
sudo yum remove docker \
                  docker-client \
                  docker-client-latest \
                  docker-common \
                  docker-latest \
                  docker-latest-logrotate \
                  docker-logrotate \
                  docker-selinux \
                  docker-engine-selinux \
                  docker-engine

#SET UP THE REPOSITORY
#Install required packages. yum-utils provides the yum-config-manager utility, and device-mapper-persistent-data and lvm2 are required by the devicemapper storage driver.
 sudo yum install -y yum-utils \
  device-mapper-persistent-data \
  lvm2

#Use the following command to set up the stable repository. You always need the stable repository, even if you want to install builds from the edge or test repositories as well.
 sudo yum-config-manager \
    --add-repo \
    https://download.docker.com/linux/centos/docker-ce.repo

#Optional: Enable the edge and test repositories. These repositories are included in the docker.repo file above but are disabled by default. You can enable them alongside the stable repository.
sudo yum-config-manager --enable docker-ce-edge
sudo yum-config-manager --enable docker-ce-test
#You can disable the edge or test repository by running the yum-config-manager command with the --disable flag. To re-enable it, use the --enable flag. The following command disables the edge repository.
sudo yum-config-manager --disable docker-ce-edge

#INSTALL DOCKER CE
#Install the latest version of Docker CE, or go to the next step to install a specific version:
sudo yum install docker-ce

#If prompted to accept the GPG key, verify that the fingerprint matches 060A 61C5 1B55 8A7F 742B 77AA C52F EB6B 621E 9F35, and if so, accept it
#Got multiple Docker repositories?
#If you have multiple Docker repositories enabled, installing or updating without specifying a version in the yum install or yum update command always installs the highest possible version, which may not be appropriate for your stability needs.
#Docker is installed but not started. The docker group is created, but no users are added to the group.
#To install a specific version of Docker CE, list the available versions in the repo, then select and install:
#a. List and sort the versions available in your repo. This example sorts results by version number, highest to lowest, and is truncated:
yum list docker-ce --showduplicates | sort -r

#Start Docker.
sudo systemctl start docker

#Verify that docker is installed correctly by running the hello-world image.
 sudo docker run hello-world

docker-compose快速直接執行:
#Run this command to download the latest version of Docker Compose:
sudo curl -L "https://github.com/docker/compose/releases/download/1.22.0/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose

#Apply executable permissions to the binary:
sudo chmod +x /usr/local/bin/docker-compose

#Test the installation.
docker-compose --version


參考:

安裝docker和docker-compose

具體安裝步驟:

注意:Docker安裝要求Linux 3.10以上版本,用uname -a命令可查看到。

安裝之後,可查看版本:

$ docker -v
$ docker-compose -v

然後把當前用戶加到docker用戶組裏面:

$ sudo gpasswd -a ${USER} docker

就不用每次啓動Docker都得加sudo了。

注意,執行gpasswd命令之後要重新登陸纔有效。

來源: https://www.awaimai.com/2120.html


阿里雲服務器在搞限時活動優惠卷, 100多個產品通用, 需要的自取. 注意, 領取的優惠券30天內有效,儘快使用!
領取鏈接:
https://promotion.aliyun.com/ntms/act/ambassador/sharetouser.html?userCode=s306eooi&utm_source=s306eooi

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章