租云服务器及配docker环境

新租ECS服务器初始设置

以阿里云服务器为例: 云服务器管理控制台 (aliyun.com)

用终端ssh远程连接

1
$ ssh root@47.113.219.85

看内存和cpu信息

1
2
$ free -h
$ cat /proc/cpuinfo

root用户权限太大,能对系统文件进行操作。以防万一,一般使用新建用户

1
2
$ adduser acs
$ # 输入新用户密码

给用户acs分配sudo权限

1
$ usermod -aG sudo acs

配置免密登录

  1. 在本地终端创建配置文件~/.ssh/config 然后在文件中输入:

    1
    2
    3
    Host aliyun
    HostName IP地址或域名
    User 用户名
    之后再使用服务器时,可以直接使用别名aliyun

  2. 创建密钥

    1
    $ ssh-keygen
    然后一直回车即可。 执行结束后,~/.ssh/目录下会多两个文件:

    • id_rsa:私钥
    • id_rsa.pub:公钥

之后想免密码登录哪个服务器,就将公钥传给哪个服务器即可。

使用如下命令一键添加公钥:

1
$ ssh-copy-id aliyun
3. 登录
1
$ ssh aliyun # ssh 别名,直接登录
4. 断开连接 ctrl + d

配置毛坯环境

使用scp配置其他服务器的vim和tmux 直接将祖传文件.bashrc, .vimrc, .tmux.conf传到服务器用户目录

1
$ scp .bashrc .vimrc .tmux.conf aliyun:/home/acs/

安装tmux

1
2
$ sudo apt-get update
$ sudo apt-get install tmux

安装 Docker

Install Docker Engine on Ubuntu | Docker Documentation docker的主要优点是方便迁移。 ### Set up the repository 1. Update the apt package index and install packages to allow apt to use a repository over HTTPS:

1
$ sudo apt-get update
2. Add Docker’s official GPG key:
1
$ sudo apt-get install ca-certificates curl gnupg lsb-release
3. Use the following command to set up the stable repository. To add the nightly or test repository, add the word nightly or test (or both) after the word stable in the commands below.
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

Install Docker Engine

Update the apt package index, and install the latest version of Docker Engine, containerd, and Docker Compose

1
2
$ sudo apt-get update
$ sudo apt-get install docker-ce docker-ce-cli containerd.io docker-compose-plugin


租云服务器及配docker环境
https://nessaj7.github.io/2022/05/13/38bd162365d1.html
作者
kuhn
发布于
2022年5月13日
许可协议