Skip to content

Commit

Permalink
add nextcloud-postgres sample
Browse files Browse the repository at this point in the history
Signed-off-by: Anca Iordache <anca.iordache@docker.com>
  • Loading branch information
Anca Iordache committed Mar 18, 2020
1 parent 282b212 commit 0b3ff4c
Show file tree
Hide file tree
Showing 3 changed files with 90 additions and 0 deletions.
64 changes: 64 additions & 0 deletions nextcloud-postgres/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
## Nextcloud with Postgres database
This example defines one of the base setups for Nextcloud. More details on how to
further customize the installation and the compose file can be found on the
[official image page](https://hub.docker.com/_/nextcloud).


Project structure:
```
.
├── docker-compose.yaml
└── README.md
```

[_docker-compose.yaml_](docker-compose.yaml)
```
services:
nc:
image: nextcloud:apache
ports:
- 80:80
...
db:
image: postgres:alpine
...
```

When deploying this setup, docker-compose maps the nextcloud container port 80 to
port 80 of the host as specified in the compose file.

## Deploy with docker-compose

```
$ docker$ compose up -d
Creating network "nextcloud-postgres_default" with the default driver
Creating volume "nextcloud-postgres_nc_data" with default driver
Pulling nc (nextcloud:apache)...
....
....
Status: Downloaded newer image for postgres:alpine
Creating nextcloud-postgres_nc_1 ... done
Creating nextcloud-postgres_db_1 ... done
```


## Expected result

Check containers are running and the port mapping:
```
$ docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
9884a9cc0144 postgres:alpine "docker-entrypoint.s…" 12 minutes ago Up 12 minutes 5432/tcp nextcloud-postgres_db_1
bae385bee48b nextcloud:apache "/entrypoint.sh apac…" 12 minutes ago Up 12 minutes 0.0.0.0:80->80/tcp nextcloud-postgres_nc_1
```

Navigate to `http://localhost:80` in your web browser to access the installed
Nextcloud service.

![page](output.jpg)

Stop and remove the containers

```
$ docker-compose down
```
26 changes: 26 additions & 0 deletions nextcloud-postgres/docker-compose.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
version: '3.7'
services:
nc:
image: nextcloud:apache
environment:
- POSTGRES_HOST=db
- POSTGRES_PASSWORD=nextcloud
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
ports:
- 80:80
restart: always
volumes:
- nc_data:/var/www/html
db:
image: postgres:alpine
environment:
- POSTGRES_PASSWORD=nextcloud
- POSTGRES_DB=nextcloud
- POSTGRES_USER=nextcloud
restart: always
volumes:
- db_data:/var/lib/postgresql/data
volumes:
db_data:
nc_data:
Binary file added nextcloud-postgres/output.jpg
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit 0b3ff4c

Please sign in to comment.