Reference :Docker官网-Install Docker Engine on Ubuntu
Install and configure docker and docker-compose based on CentOS7
一、 Install using the Apt repository
1.1 Set up Docker’s Apt repository
1.1.1 Add Docker’s official GPG key
# Add Docker's official GPG key:
sudo apt-get update
sudo apt-get install ca-certificates curl gnupg
sudo install -m 0755 -d /etc/apt/keyrings
curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo gpg --dearmor -o /etc/apt/keyrings/docker.gpg
sudo chmod a+r /etc/apt/keyrings/docker.gpg
1.1.2 Add the repository to Apt sources
# Add the repository to Apt sources:
echo \
"deb [arch="$(dpkg --print-architecture)" signed-by=/etc/apt/keyrings/docker.gpg] https://download.docker.com/linux/ubuntu \
"$(. /etc/os-release && echo "$VERSION_CODENAME")" stable" | \
sudo tee /etc/apt/sources.list.d/docker.list > /dev/null
sudo apt-get update
1.2 Install the Docker packages(Latest latest version)
Pay attention to install the latest version here, other 特殊版本Specific version
references: :Docker官网-Install Docker Engine on Ubuntu
To install the latest version, run
sudo apt-get install docker-ce docker-ce-cli containerd.io docker-buildx-plugin docker-compose-plugin
1.3 Verify that the Docker Engine installation is successful by running the hello-world image
sudo docker run hello-world
2. Install docker-compose
2.1 Solve Permission is not allowed
2.1.1 Set root
docker-compose-linux-x86_64_2.2.2 network disk download
/usr/local/bin
yes系统可执行目录
After downloading docker-compose-linux-x86_64_2.2.2
and uploading to /usr/local/bin
the directory, you will find a message that you cannot upload Permission is not allowed
, 发现当前Ubuntu23.04登录的用户无法登录xftp软件
because you 当前登录的用户权限不足
cannot upload the file to the directory 系统可执行目录/usr/local/bin
and you need to use the root user.
If you are 从未设置和登录过
a root user, just use su root
the switch root user directly su:认证失败
and su :Authentication failure
an error will be reported.
When installing software, etc., you may be prompted with insufficient permissions. The process of obtaining the root user is as follows ( 第一次
correct 设置和使用
root user) 注意
: root密码要记住,不要泄露
. The above is the correct root user
configured with Chinese language . For the English version, please refer to the picture below.Ubuntu23.04
第一次
设置和使用
Ubuntu23.04
相关命令注释
2.2.2 Modify the system sshd_config file
//使用root用户,输入刚才设置的root用户密码
su root
The root user cannot log in directly from the command line or graphical interface. This is because the ubuntu23.04 system 默认root用户是无法直接登录
needs to 先登录普通用户($)
use su root
the command to switch to root用户(#)
.
After the correct 设置和使用
root user, at this time 发现root用户仍然无法直接登录xftp等远程登录软件
, the desired 直接远程登录root
user 需要配置系统sshd_config文件
, the file is located /etc/ssh/sshd_config
.
//1-修改前,先备份sshd_config文件
cd /etc/ssh
#sshd_config_backup2023918为新备份文件名称
cp sshd_config sshd_config_backup2023918
或者
#sshd_config_backup2023918为新备份文件名称
sudo cp /etc/ssh/sshd_config /etc/ssh/sshd_config_backup2023918
//2-修改系统sshd_config文件
#具体的操作步骤如下:
1、编辑sshd_config
sudo vi /etc/ssh/sshd_config
或者
sudo vim /etc/ssh/sshd_config
2、使用i键或者insert键开启编辑模式,如果你第一次使用此模式,大概率使用↑ ↓ ← → 方向键时会变成ABCD
字符,如何解决问题,使得可以使用方向键来移动光标,编辑修改文件。
参考2.2 解决insert模式下按方向键ABCD字母无法移动光标修改文件
3、将port 22前面的 #符号删除。
在Authentication的配置后面,增加上 PermitRootLogin yes ,表示允许root登录。
4、保存(ESC键退出i模式,:wq!保存并且退出,!表示强制) (这里是"冒号:"、"字母w"、“字母q”、“感叹号!”,依次按)
5、cat /etc/ssh/sshd_config 或者cat sshd_config 查看是否修改成功
6、重启SSH服务(最后一步)。
service ssh restart
或者
/etc/init.d/ssh restart
备份sshd_config文件
修改系统sshd_config文件
cat查看是否修改成功
重启SSH服务(最后一步)
, then exit the system and log in again. At the same time, root(#)用户
you can already 直接登录
log in to software remotely such as xftp. And if you want to use the root user in the command line or graphical interface, you need to 先登录普通用户($)
use su root
the command to switch to root用户(#)
.
注意
末尾
: It will be displayed next to the normal user name , and will be displayed next to 美元符号$
the root user name , so that different types of users can be distinguished.末尾
显示#符号
2.2 Solve the problem that pressing the arrow keys ABCD letters in insert mode cannot move the cursor to modify the file
Ubuntu方向键变成字母
of解决办法
# 1、卸载系统的vi编辑器
sudo apt-get remove vim-common
# 2、安装最新的vim编辑器
sudo apt-get install vim
2.3 Upload successfully using root user
2.4 Install docker-compose
//进入/usr/local/bin目录
cd /usr/local/bin
//命令改名或者通过xftp软件工具选中右击重命名来改名
//执行完命令后,只存在一个docker-compose文件
mv docker-compose-linux-x86_64_2.2.2 docker-compose
或者
//复制docker-compose-linux-x86_64_2.2.2为docker-compose
//执行完命令后,存在两个文件docker-compose-linux-x86_64_2.2.2和docker-compose
cp docker-compose-linux-x86_64_2.2.2 docker-compose
#授权让当前文件是可以执行的,允许执行,有执行的权限。
//任意目录下
chmod +x /usr/local/bin/docker-compose
或者
//已经处于/usr/local/bin/目录下就执行这个命令
chmod +x docker-compose
#检查版本,正常情况下会显示:Docker Compose version v2.2.2
docker-compose --version
或者
docker-compose version
View docker and docker-compose versions
//查看docker客户端和服务器版本
docker version
//只查看docker服务器版本
docker --version
//查看docker-compose版本
docker-compose --version
或者
docker-compose version
3. Reference articles
Docker官网-Install Docker Engine on Ubuntu
Install and configure docker and docker-compose based on CentOS7