Docker

卸载旧版本

sudo apt-get remove docker docker-engine docker.io containerd runc

更新仓库

sudo apt-get update

安装依赖

sudo apt-get install \
    apt-transport-https \
    ca-certificates \
    curl \
    gnupg-agent \
    software-properties-common

添加 Docker 的官方 GPG 密钥:

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | sudo apt-key add -

检查密钥

sudo apt-key fingerprint 0EBFCD88

设置稳定版仓库

sudo add-apt-repository \
   "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
  $(lsb_release -cs) \
  stable"

安装

sudo apt-get install docker-ce docker-ce-cli containerd.io

开机自启

systemctl enable docker.service

在运行docker容器时可以加如下参数来保证每次docker服务重启后容器也自动重启:

docker run --restart=always

如果已经启动了则可以使用如下命令:

docker update --restart=always <CONTAINER ID>

Nginx

拉取镜像

docker pull nginx

启动

docker run --name docker-nginx -d -p 80:80 -v /etc/docker/docker-nginx/nginx.conf:/etc/nginx/nginx.conf:ro -v /etc/docker/docker-nginx/conf.d:/etc/nginx/conf.d nginx

Postgres

拉取镜像

docker pull postgres:latest

创建卷进行持久化

docker volume create pgdata

启动

docker run -v pgdata:/var/lib/postgres/data -p 5432:5432 -e POSTGRES_PASSWORD=970306 -d postgres:latest

nvm

脚本安装

curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash

环境变量

export NVM_DIR="$([ -z "${XDG_CONFIG_HOME-}" ] && printf %s "${HOME}/.nvm" || printf %s "${XDG_CONFIG_HOME}/nvm")"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"

yarn

仓库

curl -sS https://dl.yarnpkg.com/debian/pubkey.gpg | sudo apt-key add -

脚本安装

sudo apt install yarn