You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The YOURLS instance accepts [a number of environment variables for configuration](https://yourls.org/#Config).
69
-
A few notable/important examples for using this Docker image include:
70
+
The YOURLS instance accepts a number of environment variables for configuration, see *Environment Variables* section below.
70
71
71
-
-`-e YOURLS_DB_HOST=...` (defaults to the IP and port of the linked `mysql` container)
72
-
-`-e YOURLS_DB_USER=...` (defaults to "root")
73
-
-`-e YOURLS_DB_PASS=...` (defaults to the value of the `MYSQL_ROOT_PASSWORD` environment variable from the linked `mysql` container)
74
-
-`-e YOURLS_DB_NAME=...` (defaults to "yourls")
75
-
-`-e YOURLS_DB_PREFIX=...` (defaults to "yourls_", only set this when you need to override the default table prefix)
76
-
-`-e YOURLS_COOKIEKEY=...` (default to unique random SHA1s)
77
-
-`-e YOURLS_SITE=...` (yourls instance url)
78
-
-`-e YOURLS_USER=...` (yourls instance user name)
79
-
-`-e YOURLS_PASS=...` (yourls instance user password)
72
+
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`):
80
73
81
-
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.
74
+
```console
75
+
$ docker run --name some-yourlss -e YOURLS_DB_HOST=10.1.2.3:3306 \
Then, access it via `http://localhost:8080/admin/` or `http://host-ip:8080/admin/` in a browser.
87
+
Then, access it via `http://localhost:8080/admin/` or `http://<host-ip>:8080/admin/` in a browser.
90
88
91
-
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`):
89
+
**Note:** On first instantiation, reaching the root folder will generate an error. Access the YOURLS administration interface via the path `/admin/`.
90
+
91
+
## Environment Variables
92
+
93
+
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.
94
+
The YOURLS instance accepts [a number of environment variables for configuration](https://yourls.org/#Config).
95
+
A few notable/important examples for using this Docker image include the following.
96
+
97
+
### `YOURLS_SITE`
98
+
99
+
**Required.**
100
+
YOURLS instance URL, no trailing slash, lowercase.
Host, user (defaults to "root") and password for the database.
123
+
124
+
### `YOURLS_DB_NAME`
125
+
126
+
**Optional.**
127
+
Database name, defaults to "yourls". The database must have been created before installing YOURLS.
128
+
129
+
### `YOURLS_DB_PREFIX`
130
+
131
+
**Optional.**
132
+
Database tables prefix, defaults to "yourls_". Only set this when you need to override the default table prefix.
133
+
134
+
## Docker Secrets
135
+
136
+
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:
92
137
93
138
```console
94
-
$ docker run --name some-yourlss -e YOURLS_DB_HOST=10.1.2.3:3306 \
$ docker run --name some-yourls -e YOURLS_DB_PASS_FILE=/run/secrets/mysql-root ... -d yourls:tag
96
140
```
97
141
142
+
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`.
143
+
98
144
## ... via [`docker stack deploy`](https://docs.docker.com/engine/reference/commandline/stack_deploy/) or [`docker-compose`](https://github.com/docker/compose)
99
145
100
146
Example `stack.yml` for `yourls`:
@@ -116,15 +162,16 @@ services:
116
162
YOURLS_PASS: example_password
117
163
118
164
mysql:
119
-
image: mysql:5.7
165
+
image: mysql
120
166
restart: always
121
167
environment:
122
168
MYSQL_ROOT_PASSWORD: example
169
+
MYSQL_DATABASE: yourls
123
170
```
124
171
125
-
[](http://play-with-docker.com?stack=https://raw.githubusercontent.com/docker-library/docs/be1a84b44ec3c028aa0ac5a9c8e413e43dfe05e4/yourls/stack.yml)
172
+
[](http://play-with-docker.com?stack=https://raw.githubusercontent.com/docker-library/docs/6dba1507190ff91149046ce4bcbac43529d76bd4/yourls/stack.yml)
126
173
127
-
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/admin/`, `http://localhost:8080/admin/`, or `http://host-ip:8080/admin/` (as appropriate).
174
+
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/admin/`, `http://localhost:8080/admin/`, or `http://<host-ip>:8080/admin/` (as appropriate).
0 commit comments