快速配置docker

1、编辑数据源

不会vim的可以用nano
apt install nano
nano /etc/apt/sources.list
编辑完按ctrl + x 按 y 再按回车 保存完成

vi /etc/apt/sources.list

删除全部内容并修改为

deb http://mirrors.aliyun.com/ubuntu/ xenial main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-security main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-updates main restricted universe multiverse
deb http://mirrors.aliyun.com/ubuntu/ xenial-backports main restricted universe multiverse

2、更新数据源

apt-get update

旧版本的 Docker 称为 docker 或者 docker-engine,使用以下命令卸载旧版本:

  apt-get remove docker \
           docker-engine \
           docker.io

3、使用脚本自动安装或者APT安装

脚本自动安装

APT安装

4、启动 Docker CE

sudo systemctl enable docker

sudo systemctl start docker

5、安装docker-compose

apt install docker-compose

6、创建镜像yml配置(不能按tab键)

mkdir /usr/local/docker

cd /usr/local/docker

vi docker-compose.yml

7、tomcat 配置

version: ‘3.1’
services:
tomcat:
restart: always
image: tomcat
container_name: tomcat
ports:
- 8080:8080
volumes:
- /usr/local/docker/tomcat/webapps/test:/usr/local/tomcat/webapps/ROOT
environment:
TZ: Asia/Shanghai

8、MySQL配置

MySQL5
version: ‘3.1’
services:
mysql:
restart: always
image: mysql:5.7.22
container_name: mysql
ports:
- 3306:3306
environment:
TZ: Asia/Shanghai
MYSQL_ROOT_PASSWORD: 123456
command:
–character-set-server=utf8mb4
–collation-server=utf8mb4_general_ci
–explicit_defaults_for_timestamp=true
–lower_case_table_names=1
–max_allowed_packet=128M
–sql-mode=“STRICT_TRANS_TABLES,NO_AUTO_CREATE_USER,NO_ENGINE_SUBSTITUTION,NO_ZERO_DATE,NO_ZERO_IN_DATE,ERROR_FOR_DIVISION_BY_ZERO”
volumes:
- mysql-data:/var/lib/mysql

volumes:
mysql-data:

8、MySQL8配置

version: ‘3.1’
services:
db:
image: mysql
restart: always
environment:
MYSQL_ROOT_PASSWORD: 123456
command:
–default-authentication-plugin=mysql_native_password
–character-set-server=utf8mb4
–collation-server=utf8mb4_general_ci
–explicit_defaults_for_timestamp=true
–lower_case_table_names=1
ports:
- 3306:3306
volumes:
- ./data:/var/lib/mysql

adminer:
image: adminer
restart: always
ports:
- 8080:8080

#Dockerfile的写法(用的jetty)

FROM jetty

WORKDIR /var/lib/jetty/webapps

RUN mkdir ROOT

WORKDIR /var/lib/jetty/webapps/ROOT

COPY my-shop-web-admin-1.0.0-SNAPSHOT.zip /var/lib/jetty/webapps/ROOT

RUN unzip my-shop-web-admin-1.0.0-SNAPSHOT.zip

WORKDIR /var/lib/jetty

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值