服务器: CentOS 7
容器: Docker 18
环境: MySQL 5.7 + Gogs:0.11.66
1.Docker容器内安装MySQL
1 | docker pull mysql |
error: database is uninitialized and password option is not specified
You need to specify one of MYSQL_ROOT_PASSWORD, MYSQL_ALLOW_EMPTY_PASSWORD and MYSQL_RANDOM_ROOT_PASSWORD
进入MySQL终端
1 | docker exec -it 63ca57bd6dc5 /bin/bash |
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 12
Server version: 8.0.12 MySQL Community Server - GPL
Copyright (c) 2000, 2018, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql>
查看已经创建的容器1
docker ps -a
查看正在运行的容器1
docker ps -s
docker stop mymysql
docker rm mymysql
docker rmi 6a834f03bd02
防火墙开启3306端口
1 | firewall-cmd --query-port=3306/tcp |
1 | exit |
MySQL Workbench连接
2.Docker容器内安装Gogs
https://github.com/gogs/gogs/tree/master/docker
# Pull image from Docker Hub.
$ docker pull gogs/gogs:0.11.66
# Create local directory for volume.
$ mkdir -p /var/gogs
# Use `docker run` for the first time.
$ docker run --name=mygogs -p 10022:22 -p 10080:3000 -v /var/gogs:/data gogs/gogs:0.11.66
# Use `docker start` if you have stopped it.
$ docker start gogs
$ mysql -u root -p
mysql> # (输入密码)
mysql> create user 'gogs'@'localhost' identified by '密码';
mysql> grant all privileges on gogs.* to 'gogs'@'localhost';
mysql> flush privileges;
mysql> exit;
然后访问 http://192.168.1.105:10080/
Bingo: