Skip to content

Commit 6dba150

Browse files
authored
Review YOURLS image usage doc to reflect latest changes (#2028)
1 parent be06eee commit 6dba150

File tree

2 files changed

+65
-18
lines changed

2 files changed

+65
-18
lines changed

yourls/content.md

Lines changed: 63 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ YOURLS is a set of PHP scripts that will allow you to run Your Own URL Shortener
88

99
# How to use this image
1010

11+
## Start a `%%IMAGE%%` server instance
12+
1113
```console
1214
$ docker run --name some-%%REPO%% --link some-mysql:mysql \
1315
-e YOURLS_SITE="https://example.com" \
@@ -16,39 +18,83 @@ $ docker run --name some-%%REPO%% --link some-mysql:mysql \
1618
-d %%IMAGE%%
1719
```
1820

19-
The YOURLS instance accepts [a number of environment variables for configuration](https://yourls.org/#Config).
20-
A few notable/important examples for using this Docker image include:
21+
The YOURLS instance accepts a number of environment variables for configuration, see *Environment Variables* section below.
2122

22-
- `-e YOURLS_DB_HOST=...` (defaults to the IP and port of the linked `mysql` container)
23-
- `-e YOURLS_DB_USER=...` (defaults to "root")
24-
- `-e YOURLS_DB_PASS=...` (defaults to the value of the `MYSQL_ROOT_PASSWORD` environment variable from the linked `mysql` container)
25-
- `-e YOURLS_DB_NAME=...` (defaults to "yourls")
26-
- `-e YOURLS_DB_PREFIX=...` (defaults to "yourls_", only set this when you need to override the default table prefix)
27-
- `-e YOURLS_COOKIEKEY=...` (default to unique random SHA1s)
28-
- `-e YOURLS_SITE=...` (yourls instance url)
29-
- `-e YOURLS_USER=...` (yourls instance user name)
30-
- `-e YOURLS_PASS=...` (yourls instance user password)
23+
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`):
3124

32-
If the `YOURLS_DB_NAME` specified does not already exist on the given MySQL server, it will be created automatically upon startup of the `yourls` container, provided that the `YOURLS_DB_USER` specified has the necessary permissions to create it.
25+
```console
26+
$ docker run --name some-%%REPO%%s -e YOURLS_DB_HOST=10.1.2.3:3306 \
27+
-e YOURLS_DB_USER=... -e YOURLS_DB_PASS=... -d %%IMAGE%%
28+
```
29+
30+
## Connect to the YOURLS administration interface
3331

3432
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:
3533

3634
```console
3735
$ docker run --name some-%%REPO%% --link some-mysql:mysql -p 8080:80 -d %%IMAGE%%
3836
```
3937

40-
Then, access it via `http://localhost:8080/admin/` or `http://host-ip:8080/admin/` in a browser.
38+
Then, access it via `http://localhost:8080/admin/` or `http://<host-ip>:8080/admin/` in a browser.
4139

42-
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`):
40+
**Note:** On first instantiation, reaching the root folder will generate an error. Access the YOURLS administration interface via the path `/admin/`.
41+
42+
## Environment Variables
43+
44+
When you start the `yourls` image, you can adjust the configuration of the YOURLS instance by passing one or more environment variables on the `docker run` command line.
45+
The YOURLS instance accepts [a number of environment variables for configuration](https://yourls.org/#Config).
46+
A few notable/important examples for using this Docker image include the following.
47+
48+
### `YOURLS_SITE`
49+
50+
**Required.**
51+
YOURLS instance URL, no trailing slash, lowercase.
52+
53+
Example: `YOURLS_SITE="https://example.com"`
54+
55+
### `YOURLS_USER`
56+
57+
**Required.**
58+
YOURLS instance username.
59+
60+
Example: `YOURLS_USER="example_username"`
61+
62+
### `YOURLS_PASS`
63+
64+
**Required.**
65+
YOURLS instance password.
66+
67+
Example: `YOURLS_USER="example_password"`
68+
69+
### `YOURLS_DB_HOST`, `YOURLS_DB_USER`, `YOURLS_DB_PASS`
70+
71+
**Optional if linked `mysql` container.**
72+
73+
Host, user (defaults to "root") and password for the database.
74+
75+
### `YOURLS_DB_NAME`
76+
77+
**Optional.**
78+
Database name, defaults to "yourls". The database must have been created before installing YOURLS.
79+
80+
### `YOURLS_DB_PREFIX`
81+
82+
**Optional.**
83+
Database tables prefix, defaults to "yourls_". Only set this when you need to override the default table prefix.
84+
85+
## Docker Secrets
86+
87+
As an alternative to passing sensitive information via environment variables, `_FILE` may be appended to the previously listed environment variables, causing the initialization script to load the values for those variables from files present in the container. In particular, this can be used to load passwords from Docker secrets stored in `/run/secrets/<secret_name>` files. For example:
4388

4489
```console
45-
$ docker run --name some-%%REPO%%s -e YOURLS_DB_HOST=10.1.2.3:3306 \
46-
-e YOURLS_DB_USER=... -e YOURLS_DB_PASS=... -d %%IMAGE%%
90+
$ docker run --name some-%%REPO%% -e YOURLS_DB_PASS_FILE=/run/secrets/mysql-root ... -d %%IMAGE%%:tag
4791
```
4892

93+
Currently, this is supported for `YOURLS_DB_HOST`, `YOURLS_DB_USER`, `YOURLS_DB_PASS`, `YOURLS_DB_NAME`, `YOURLS_DB_PREFIX`, `YOURLS_SITE`, `YOURLS_USER`, and `YOURLS_PASS`.
94+
4995
## %%STACK%%
5096

51-
Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml up`), wait for it to initialize completely, and visit `http://swarm-ip:8080/admin/`, `http://localhost:8080/admin/`, or `http://host-ip:8080/admin/` (as appropriate).
97+
Run `docker stack deploy -c stack.yml %%REPO%%` (or `docker-compose -f stack.yml up`), wait for it to initialize completely, and visit `http://swarm-ip:8080/admin/`, `http://localhost:8080/admin/`, or `http://<host-ip>:8080/admin/` (as appropriate).
5298

5399
## Adding additional libraries / extensions
54100

yourls/stack.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,8 @@ services:
1414
YOURLS_PASS: example_password
1515

1616
mysql:
17-
image: mysql:5.7
17+
image: mysql
1818
restart: always
1919
environment:
2020
MYSQL_ROOT_PASSWORD: example
21+
MYSQL_DATABASE: yourls

0 commit comments

Comments
 (0)