docker-install

Ling Yu
安装Docker
服务器上执行以下命令安装docker, 安装完成后执行第二条命令,启动并设置开机启动docker。
curl -fsSL https://get.docker.com | bash -s docker --mirror Aliyun
systemctl enable --now docker
安装docker-compose
curl -L https://get.daocloud.io/docker/compose/releases/download/v2.16.0/docker-compose-`uname -s`-`uname -m` -o /usr/local/bin/docker-compose && chmod +x /usr/local/bin/docker-compose
Docker命令
docker run \
--restart=always \
--privileged \
--ulimit core=-1 \
-idt \
-p 2222:22 \
-v /etc/localtime:/etc/localtime \
--name=my_ubuntu \
ubuntu:20.04 \
/bin/bash
# 查看容器状态
docker ps -a
# 查看对应的端口是否被docker容器监听
netstat -tunlp | grep ‘2222’
# 进入容器,安装ssh,修改配置文件允许root用户登录,修改root用户密码,安装cmake,g++
docker exec -it cf0b23894466 /bin/bash
# 修改root密码
passwd
配置ssh
vim /etc/ssh/sshd_config
UsePAM no
UsePrivilegeSeparation no
PermitRootLogin yes
PasswordAuthentication yes
/etc/init.d/ssh restart
启动ssh并设置为开机启动
systemctl start sshd
systemctl enable sshd
安装常用软件
apt-get update
apt-get install -y openssh-client
apt-get install -y openssh-server
apt-get install -y cmake
apt-get install -y g++
apt-get install -y vim
PermitRootLogin yes #允许root用户ssh登录
UsePAM no ##禁用PAM
/etc/init.d/ssh restart
# 设置ssh密码
passwd root