Reputation: 4895
I have a remote docker container which I pulled and is currently running using:
docker pull bamos/openface
docker run -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
I also have a local directory at
/Users/name/Documents/my-project
I need to import openface
from scripts inside my-project
while developing in ipython
, but I do not know how to mount my-project
onto openface
, or should it be the other way around.
In general, I have been reading the docs here https://docs.docker.com/engine/tutorials/dockervolumes/#mount-a-host-directory-as-a-data-volume, but am still very confused. I would greatly appreciated it if someone could
openface
from my-project
Thank you!
============================================================== EDIT:
right now I am doing:
docker run -v /Users/name/Documents/my-project:/root/my-project -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
and it seems to be working.
Upvotes: 1
Views: 3233
Reputation: 1875
So, I will just point some topics you can study and give thoughts that I think can be useful for you.
As you are still learning, let's go through these topics:
Using a docker image
This is what you already know. Run docker run -v /Users/name/Documents/my-project:/root/my-project -p 9000:9000 -p 8000:8000 -t -i bamos/openface /bin/bash
and start using it. Run some commands and see the capabilities of the image provided.
Use cases (for me):
docker run --name some-cassandra -d cassandra:latest
and it is already workingNot so good for now, but it is interesting to use.
Custom a docker image
Instead of using ephemeral images, you can create your own. So, you need to learn about Dockerfile. Here is a simple example:
FROM bamos/openface
RUN pip install flask
COPY myentrypoint.sh
CMD ["myentrypoint.sh"]
Fast explanation:
bamos/openface
With this image, just save with name Dockerfile
and run docker build -t
chibro2/myopenface .
, and then you have your own image with an extra package.
entrypoint is a default sh command that will start something (for example, a web server). If you have an online instance (AWS, for example) you can run your docker, and it will start your web service. If you tested locally, you should have the same results online. One common problem is testing with different versions (like python3 local, and python2 at the server).
Use cases:
Check: https://www.digitalocean.com/community/tutorials/docker-explained-using-dockerfiles-to-automate-building-of-images https://docs.docker.com/engine/reference/builder/
Integrate some docker images
One thing that I really like at Docker, is the docker compose. You easily work with several docker images that work with each other. An example of docker-compose:
version: '3'
services:
db:
image: postgres
web:
build: .
command: python3 manage.py runserver 0.0.0.0:8000
volumes:
- .:/code
ports:
- "8000:8000"
depends_on:
- db
Fast explanation:
python3 manage.py runserver 0.0.0.0:8000
.Ps.: Yes, it use the code as a volume, but this something I don't recommend for production, but recommend for development (so, you easily change your code, and don't need to build the image).
With docker-compose, we easily integrate several projects and start all with a single command: docker-compose up
Use cases:
docker-compose scale web=2
will create 2 instances of your web server).Check this quickstart: https://docs.docker.com/compose/django/
Conclusion
There is too much to learn about docker. I can't give a very good answer on this, but I hope I could help a little.
Possible future steps is to use Docker Machine and Docker Swarm.
Upvotes: 1