# run mongo
$ docker run --rm --name my-mongo -it -p 27017:27017 mongo:3.2.7
# or as a daemon
$ docker run --name my-mongo -d mongo:3.2.7
# connect to the previous container.. with another container
$ docker run -it --link my-mongo:mongo --rm mongo:3.2.7 sh -c 'exec mongo "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT/test"'
A user wants profile data from an app.
- User makes a request to a client (website, mobile app, etc).
- Client (may) redirect the user to auth server login form.
- User logs into the auth server.
- Auth server validates previous credentials and returns an access token to the client.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
echo '{"cities": [{"name": "Barcelona"}, {"name": "Copenhagen"}, {"name": "Edinburgh"}, {"name": "Hanoi"}]}' > /tmp/cities.json | |
docker run -d -p 80:80 -v /tmp/cities.json:/data/db.json clue/json-server | |
# Listing my favourite cities | |
curl http://localhost/cities | |
[ | |
{"name": "Barcelona"}, | |
{"name": "Copenhagen"}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '3' | |
networks: | |
test_net: | |
services: | |
webserver: | |
image: nginx:alpine | |
command: sh -c 'sleep 10 && nginx -g "daemon off;"' | |
networks: | |
- test_net |
Three ways to copy and share data to a Docker container:
-
Providing data on build time: Docker ADD vs COPY
-
Providing data on run time: How to copy files to or from a Docker container
-
Sharing data via volumes: Using volumes in Docker Compose
OlderNewer