Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
Next revision
Previous revision
Last revisionBoth sides next revision
doc:docker:dev [2014/08/27 07:43] admindoc:docker:dev [2015/03/31 12:50] – [Building Docker images] daniel86
Line 1: Line 1:
-====== KnowRob & Docker --- developer documentation ======+====== KnowRob & Docker -- developer documentation ====== 
 + 
 +This page lists information for developers that would like to modify, update and develop the docker images. If you would only like to start the existing docker containers, please have a look [[/doc/docker|here]]. 
  
 ===== Building Docker images===== ===== Building Docker images=====
Line 5: Line 8:
 The Dockerfiles for the KnowRob containers can be found in this repository: https://github.com/knowrob/docker. You can build docker images from them using The Dockerfiles for the KnowRob containers can be found in this repository: https://github.com/knowrob/docker. You can build docker images from them using
 <code bash> <code bash>
-  cd ~/docker/knowrob-daemon +cd ~/docker/hydro-knowrob/hydro-knowrob-base 
-  docker build -t knowrob/hydro-knowrob-daemon .+docker build -t knowrob/hydro-knowrob-base . 
 + 
 +cd ~/docker/hydro-knowrob/hydro-knowrob-daemon 
 +docker build -t knowrob/hydro-knowrob-daemon .
  
-  cd ~/docker/knowrob-interactive +cd ~/docker/hydro-knowrob/hydro-knowrob-interactive 
-  docker build -t knowrob/hydro-knowrob-interactive .+docker build -t knowrob/hydro-knowrob-interactive .
  
-  cd ~/docker/webapp +cd ~/docker/webapps/easeapp 
-  docker build -t knowrob/webrob .+docker build -t openease/easeapp . 
 + 
 +cd ~/docker/webapps/login 
 +docker build -t openease/login . 
 + 
 +cd ~/docker/webapps/knowrob 
 +docker build -t openease/knowrob .
 </code> </code>
  
 You can tag a version of an image using You can tag a version of an image using
-  docker tag 18df3323a0d8 knowrob/webrob:0.1.0+  docker tag 18df3323a0d8 openease/knowrob:0.1.0
  
 ===== Sharing images via Docker hub ===== ===== Sharing images via Docker hub =====
Line 23: Line 35:
 <code bash> <code bash>
   # upload image:   # upload image:
-  docker pull knowrob/hydro-knowrob-daemon+  docker push knowrob/hydro-knowrob-daemon
  
-  # download images (this can also be done with the 'update-images' script)+  # download images (this can also be done with the 'update-containers' script)
   docker pull knowrob/hydro-knowrob-daemon   docker pull knowrob/hydro-knowrob-daemon
   docker pull knowrob/webrob   docker pull knowrob/webrob
   docker pull knowrob/knowrob_data   docker pull knowrob/knowrob_data
   docker pull knowrob/user_data   docker pull knowrob/user_data
 +  [...]
 </code> </code>
  
Line 45: Line 58:
   docker run -t -P -d knowrob/hydro-knowrob-daemon   docker run -t -P -d knowrob/hydro-knowrob-daemon
 </code> </code>
- 
-==== Web application ==== 
- 
-The web app needs access to the Docker socket, so you have to start it like this: 
-  docker run --rm -i -p 5000:5000 -v /var/run/docker.sock:/var/run/docker.sock knowrob/webrob python webrob.py 
- 
-You can then access the Web interface at http://localhost:5000 
  
  
Line 67: Line 73:
   docker run -t -P --rm --link mongo_db:mongo \   docker run -t -P --rm --link mongo_db:mongo \
          -v /home/tenorth/work/roslog:/var/roslog \          -v /home/tenorth/work/roslog:/var/roslog \
-         -i knowrob/hydro-knowrob-interactive:1.0.2 /bin/bash+         -i knowrob/hydro-knowrob-interactive /bin/bash
 </code> </code>
 Then you can run the 'mongoimport' program from within the container. Make sure to set the host correctly, i.e. to refer to the MongoDB instance in the other container: Then you can run the 'mongoimport' program from within the container. Make sure to set the host correctly, i.e. to refer to the MongoDB instance in the other container:
 <code bash> <code bash>
 +  cd /var/roslog/<experiment-id>
   mongoimport --host "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT" --db roslog --collection tf tf.json   mongoimport --host "$MONGO_PORT_27017_TCP_ADDR:$MONGO_PORT_27017_TCP_PORT" --db roslog --collection tf tf.json
-  </code>+</code>
  
  
Line 80: Line 87:
 Docker containers are cheap and usually short-lived, i.e. they can easily be started, stopped, removed and updated. The problem is how to store persistent data such as the content of a database or user-specific files. The approach we use are [[https://docs.docker.com/userguide/dockervolumes/#creating-and-mounting-a-data-volume-container|data-only containers]] -- normal containers that contain nothing but a data volume that can be mounted by the other containers that provide the applications. These data-only containers shall not be removed, but can persist over longer time, also if the application containers get updated. Docker containers are cheap and usually short-lived, i.e. they can easily be started, stopped, removed and updated. The problem is how to store persistent data such as the content of a database or user-specific files. The approach we use are [[https://docs.docker.com/userguide/dockervolumes/#creating-and-mounting-a-data-volume-container|data-only containers]] -- normal containers that contain nothing but a data volume that can be mounted by the other containers that provide the applications. These data-only containers shall not be removed, but can persist over longer time, also if the application containers get updated.
  
-In the KnowRob use case, there is one container per user (called <user>_data), and another one for common data (called knowrob_data). The user container will serve as sandbox in which users can store their files, the knowrob_data container will provide commonly used data sets. The common data container knowrob_data is [[https://docs.docker.com/userguide/dockerrepos/#automated-builds|auto-built]] on [[https://hub.docker.com/|DockerHub]] from the [[https://github.com/knowrob/knowrob_data|knowrob_data]] GithHub repository. +In the KnowRob use case, there is one container for user data (called user_data), and another one for common data (called knowrob_data). The user container will serve as sandbox in which users can store their files, the knowrob_data container will provide commonly used data sets. The common data container knowrob_data is [[https://docs.docker.com/userguide/dockerrepos/#automated-builds|auto-built]] on [[https://hub.docker.com/|DockerHub]] from the [[https://github.com/knowrob/knowrob_data|knowrob_data]] GithHub repository.
- +
- +
-==== Creating the user data containers ==== +
-The user containers are built from the user_data Dockerfile. It basically just creates a user 'ros' in order to set the permissions correctly and creates the directory '/home/ros/sandbox'. The following commands build a Docker image from this Dockerfile (needs to be done only when the Dockerfile gets updated) and start a container, in this case for the user 'demo'+
- +
-<code bash> +
-  cd docker/user-sandbox +
-  docker build -t knowrob/user_data . +
-  docker run --name demo_data knowrob/user_data true +
-</code>+
  
  
Line 108: Line 105:
 <code bash> <code bash>
   # interactive mode   # interactive mode
-  docker run -t -P -i \+  docker run -t -P -i --rm \
              --volumes-from knowrob_data \              --volumes-from knowrob_data \
-             --volumes-from demo_data \+             --volumes-from user_data \
              --name demo \              --name demo \
 +             --link mongo_db:mongo \
              knowrob/hydro-knowrob-interactive \              knowrob/hydro-knowrob-interactive \
              /bin/bash              /bin/bash
      
   # daemon mode   # daemon mode
-  docker run -t -P -d \+  docker run -t -P -d --rm\
              --volumes-from knowrob_data \              --volumes-from knowrob_data \
-             --volumes-from demo_data \+             --volumes-from user_data \
              --name demo \              --name demo \
 +             --link mongo_db:mongo \
              knowrob/hydro-knowrob-daemon              knowrob/hydro-knowrob-daemon
   </code>   </code>
-These examples are for the user 'demo', so 'demo' and 'demo_data' have to be replaced with the respective username.+These examples are for the user 'demo', so 'demo' has to be replaced with the respective username.