add sudo to docker command

This commit is contained in:
Son NK 2020-01-28 14:43:30 +07:00
parent 4edf7f2003
commit ff168b7e54

View file

@ -250,7 +250,8 @@ Now the boring DNS stuffs are done, let's do something more fun!
If you don't already have Docker installed on your server, please follow the steps on [Docker CE for Ubuntu](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/) to install Docker. If you don't already have Docker installed on your server, please follow the steps on [Docker CE for Ubuntu](https://docs.docker.com/v17.12/install/linux/docker-ce/ubuntu/) to install Docker.
Tips: if you are not using `root` user and you want to run Docker without the `sudo` prefix, add your account to `docker` group: Tips: if you are not using `root` user and you want to run Docker without the `sudo` prefix, add your account to `docker` group with the following command.
You might need to exit and ssh again to your server for this to be taken into account.
```bash ```bash
sudo usermod -a -G docker $USER sudo usermod -a -G docker $USER
@ -262,7 +263,7 @@ This Docker network will be used by the other Docker containers run in the next
Later, we will setup Postfix to authorize this network. Later, we will setup Postfix to authorize this network.
```bash ```bash
docker network create -d bridge \ sudo docker network create -d bridge \
--subnet=240.0.0.0/24 \ --subnet=240.0.0.0/24 \
--gateway=240.0.0.1 \ --gateway=240.0.0.1 \
sl-network sl-network
@ -277,20 +278,20 @@ If you have already had a Postgres database in use, you can skip this section an
Run a Postgres Docker container as your Postgres database server. Make sure to replace `myuser` and `mypassword` with something more secret 😎. Run a Postgres Docker container as your Postgres database server. Make sure to replace `myuser` and `mypassword` with something more secret 😎.
```bash ```bash
docker run -d \ sudo docker run -d \
--name sl-db \ --name sl-db \
-e POSTGRES_PASSWORD=mypassword \ -e POSTGRES_PASSWORD=mypassword \
-e POSTGRES_USER=myuser \ -e POSTGRES_USER=myuser \
-e POSTGRES_DB=simplelogin \ -e POSTGRES_DB=simplelogin \
-p 5432:5432 \ -p 5432:5432 \
--network="sl-network" \ --network="sl-network" \
postgres postgres:12.1
``` ```
To test whether the database operates correctly or not, run the following command: To test whether the database operates correctly or not, run the following command:
```bash ```bash
docker exec -it sl-db psql -U myuser simplelogin sudo docker exec -it sl-db psql -U myuser simplelogin
``` ```
you should be logged in the postgres console. Type `exit` to exit postgres console. you should be logged in the postgres console. Type `exit` to exit postgres console.
@ -383,7 +384,10 @@ query = SELECT 'smtp:127.0.0.1:20381' FROM custom_domain WHERE domain = '%s' AND
Finally, restart Postfix Finally, restart Postfix
> sudo systemctl restart postfix ```bash
sudo systemctl restart postfix
```
### Run SimpleLogin Docker containers ### Run SimpleLogin Docker containers
@ -427,10 +431,10 @@ FLASK_SECRET=put_something_secret_here
``` ```
Before running the webapp, you need to prepare the database by running the migration Before running the webapp, you need to prepare the database by running the migration:
```bash ```bash
docker run --rm \ sudo docker run --rm \
--name sl-migration \ --name sl-migration \
-v $(pwd)/dkim.key:/dkim.key \ -v $(pwd)/dkim.key:/dkim.key \
-v $(pwd)/dkim.pub.key:/dkim.pub.key \ -v $(pwd)/dkim.pub.key:/dkim.pub.key \
@ -444,7 +448,7 @@ This command could take a while to download the `simplelogin/app` docker image.
Now, it's time to run the `webapp` container! Now, it's time to run the `webapp` container!
```bash ```bash
docker run -d \ sudo docker run -d \
--name sl-app \ --name sl-app \
-v $(pwd)/simplelogin.env:/code/.env \ -v $(pwd)/simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \ -v $(pwd)/dkim.key:/dkim.key \
@ -457,7 +461,7 @@ docker run -d \
Next run the `email handler` Next run the `email handler`
```bash ```bash
docker run -d \ sudo docker run -d \
--name sl-email \ --name sl-email \
-v $(pwd)/simplelogin.env:/code/.env \ -v $(pwd)/simplelogin.env:/code/.env \
-v $(pwd)/dkim.key:/dkim.key \ -v $(pwd)/dkim.key:/dkim.key \