安装docker和docker-compose后,docker-compose.yml可以在文件的当前目录使用docker-compose up -d
命令启动容器很方便。
tomcat需要构建一下才可以使用,创建Dockerfile
文件然后在文件所在目录sudo docker build -t mycat .
(注意后面还有一个点)
FROM tomcat
WORKDIR /usr/local/tomcat
RUN rm -fr webapps
RUN mv webapps.dist webapps
然后使用docker-compose.yml运行tomcat
version: '3.1'
services:
tomcat:
restart: always
image: mycat
container_name: mycat
ports:
- 8080:8080
volumes:
- ./root:/usr/local/tomcat/webapps/ROOT
environment:
TZ: Asia/Shanghai
docker-compose.yml启动mysql,可以修改配置中密码,账号为root
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: yourpassword #你的密码
command:
--character-set-server=utf8mb4
--collation-server=utf8mb4_general_ci
--explicit_defaults_for_timestamp=true
--lower_case_table_names=1
--max_allowed_packet=2048M
--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:
docker-compose.yml启动redis
version: '3'
services:
redis:
image: redis:latest
container_name: redis
command: redis-server --requirepass yourpassword #配置redis密码
ports:
- "6379:6379"
volumes:
- ./data:/data
docker-compose.yml启动rabbitmq,可以修改账号密码
version: '3.1'
services:
rabbitmq:
restart: always
image: rabbitmq:management
container_name: rabbitmq
ports:
- 5672:5672
- 15672:15672
environment:
TZ: Asia/Shanghai
RABBITMQ_DEFAULT_USER: yourusername #修改账号
RABBITMQ_DEFAULT_PASS: yourpassword #修改密码
volumes:
- ./data:/var/lib/rabbitmq
docker-compose.yml启动nginx,在当前目录下会自动创建conf目录,在目录中创建nginx.conf文件,对nginx配置
version: '3.1'
services:
nginx:
restart: always
image: nginx
container_name: nginx
ports:
- 80:80
volumes:
- ./conf/nginx.conf:/etc/nginx/nginx.conf
- ./wwwroot:/usr/share/nginx/wwwroot
docker-compose.yml启动gitlab,访问7780端口
version: '3'
services:
gitlab-private:
image: 'twang2218/gitlab-ce-zh'
restart: always
hostname: '127.0.0.1'
environment:
TZ: 'Asia/Shanghai'
GITLAB_OMNIBUS_CONFIG: |
external_url 'http://127.0.0.1'
gitlab_rails['gitlab_shell_ssh_port'] = 2222
unicorn['port'] = 8888
nginx['listen_port'] = 80
ports:
- '7780:80'
- '8443:443'
- '2222:22'
volumes:
- ./gitlab/conf:/etc/gitlab/
- ./gitlab/data:/var/opt/gitlab
- ./gitlab/log:/var/log/gitlab
docker-compose.yml启动nextcloud,访问7786端口
version: '2'
services:
nextcloud:
image: nextcloud
ports:
- 7786:80
volumes:
- ./nextcloud:/var/www/html
restart: always
运行以下命令
git clone https://github.com/nacos-group/nacos-docker.git
cd nacos-docker
# 这里需要该版本,最新版本报错
vim example/standalone-derby.yaml #把` image: nacos/nacos-server:latest`改为`image: nacos/nacos-server:1.2.1`
docker-compose -f example/standalone-derby.yaml up -d #运行nacos