Docker Official Image packaging for YOURLS
这是官方维护的镜像的 fork YOURLS.
YOURLS 是由PHP写成的域名缩短服务。
$ docker run --name some-yourls --link some-mysql:mysql -d yourls
镜像包含如下的环境变量:
-e YOURLS_DB_HOST=...
指向数据库的ip和端口-e YOURLS_DB_USER=...
默认为 "root"-e YOURLS_DB_PASS=...
需要和mysql数据容器的MYSQL_ROOT_PASSWORD
变量一致-e YOURLS_DB_NAME=...
默认为 "yourls"-e YOURLS_TABLE_PREFIX=...
默认为空 "", 只有当你需要覆盖wp-config.php
中默认的前缀时使用-e YOURLS_COOKIEKEY=...
(default to unique random SHA1s)-e YOURLS_URL_CONVERT=...
62 包含大小写-e YOURLS_HOURS_OFFSET
时区 +8-e YOURLS_SITE
域名,需要包含 http 或者 https-e YOURLS_USER
管理员名字-e YOURLS_PASS
管理员密码
如果 YOURLS_DB_NAME
中指定的数据库,在 MySQL 容器中不存在会创建
If you'd like to be able to access the instance from the host without the container's IP, standard port mappings can be used:
$ docker run --name some-yourls --link some-mysql:mysql -p 8080:80 -d yourls
Then, access it via http://localhost:8080
or http://host-ip:8080
in a browser.
If you'd like to use an external database instead of a linked mysql
container, specify the hostname and port with YOURLS_DB_HOST
along with the password in YOURLS_DB_PASS
and the username in YOURLS_DB_USER
(if it is something other than root
):
$ docker run --name some-yourls -e YOURLS_DB_HOST=10.1.2.3:3306 \
-e YOURLS_DB_USER=... -e YOURLS_DB_PASS=... -d yourls
... via docker stack deploy
or docker-compose
Example stack.yml
for yourls
:
version: '3.1'
services:
yourls:
image: yourls
restart: always
ports:
- 8080:80
environment:
YOURLS_DB_PASS: example
mysql:
image: mysql:5.7
restart: always
environment:
MYSQL_ROOT_PASSWORD: example
Run docker stack deploy -c stack.yml yourls
(or docker-compose -f stack.yml up
), wait for it to initialize completely, and visit http://swarm-ip:8080
, http://localhost:8080
, or http://host-ip:8080
(as appropriate).
This image does not provide any additional PHP extensions or other libraries, even if they are required by popular plugins. There are an infinite number of possible plugins, and they potentially require any extension PHP supports. Including every PHP extension that exists would dramatically increase the image size.
If you need additional PHP extensions, you'll need to create your own image FROM
this one. The documentation of the php
image explains how to compile additional extensions.
The following Docker Hub features can help with the task of keeping your dependent images up-to-date:
- Automated Builds let Docker Hub automatically build your Dockerfile each time you push changes to it.
- Repository Links can ensure that your image is also rebuilt any time
yourls
is updated.
备份数据库和文件内容
docker exec yourls_db /usr/bin/mysqldump -u root --password=root yourls > yourls_db.sql
docker run --rm --volume docker-yourls_yourls_data:/temp_data --volume $(pwd):/temp_backup alpine tar cfv /temp_backup/yourls_files.tar /temp_data
The yourls
images come in many flavors, each designed for a specific use case.
This is the defacto image. If you are unsure about what your needs are, you probably want to use this one. It is designed to be used both as a throw away container (mount your source code and start the container to start your app), as well as the base to build other images off of.