免責聲明

Disclaimer (免責聲明)
繼續閱覽代表您接受以上的免責聲明.
To continue reading means you accept the above disclaimer.

2015年2月11日 星期三

docker + mongodb


//=== http://cloud-mechanic.blogspot.com/2014/08/docker-simple-service-container-example.html
Dockerfile:
VOLUME [ "/var/lib/mongodb" ]

""" ...
declares that the directory /var/lib/mongodb will be used as a mountpoint for external storage.

... """


//=== https://docs.docker.com/examples/mongodb/
""" ...
# Usage: sudo docker run --name -d /
$ sudo docker run --name mongo_instance_001 -d my/repo

...
# Usage: sudo docker run --name -d / --noprealloc --smallfiles
$ sudo docker run --name mongo_instance_001 -d my/repo --noprealloc --smallfiles

...
# Usage: sudo docker logs
$ sudo docker logs mongo_instance_001

...
# Usage: mongo --port
$ mongo --port 12345


... """



//=== https://docs.docker.com/userguide/dockerlinks/

""" ...
$ sudo docker run -d -P training/webapp python app.py
...
the -P flag was used to automatically map any network ports inside it to a random high port from the range 49153 to 65535 on our Docker host. Next, when docker ps was run, you saw that port 5000 in the container was bound to port 49155 on the host.
...
$ sudo docker ps nostalgic_morse
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
bc533791f3f5 training/webapp:latest python app.py 5 seconds ago Up 2 seconds 0.0.0.0:49155->5000/tcp nostalgic_morse
...
bind a container's ports to a specific port using the -p flag:
$ sudo docker run -d -p 5000:5000 training/webapp python app.py
...

By default the -p flag will bind the specified port to all interfaces on the host machine. But you can also specify a binding to a specific interface, for example only to the localhost.
$ sudo docker run -d -p 127.0.0.1:5000:5000 training/webapp python app.py
...
if you've bound the container port to the localhost on the host machine, then the docker port output will reflect that.
$ sudo docker port nostalgic_morse 5000
127.0.0.1:49155
...

use docker inspect to return the container's name.
$ sudo docker inspect -f "{{ .Name }}" aed84ee21bde
/web
...

The --link flag takes the form:
--link :alias
...

... """


[run mongod from repo:tag= mongo:2.2 ]
$ sudo docker run -d --name db mongo:2.2

[start a container from image myapp:mytag and link to mongodb container named 'db' with alias 'db_1']
$ sudo docker run -p 3000:3000 --link db:db_1 myapp:mytag


""" ...
inspect your linked containers with docker inspect:

$ sudo docker inspect -f "{{ .HostConfig.Links }}" myapp:mytag
[/db:/web/db]

... """

沒有留言:

張貼留言