Last active
June 10, 2017 20:43
-
-
Save orm011/49b6229c581cb394f401c33eb022af3a to your computer and use it in GitHub Desktop.
knightriderdocker
This file contains hidden or 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
# two important docker types to distinguish: $DOCKER_IMAGE vs. $DOCKER_CONTAINER. (think executable vs process) | |
# docker run takes an image and makes a container | |
# docker commit takes a container and makes an image | |
# docker start, stop, exec operate on containers only. | |
# start running a new container instance as a daemon, starting from a docker image | |
# some settings like volume mappings need to be set here | |
# you will probably need to remove the inline comments. SORRY! | |
# TODO replace them with `: <comment>` \ like in the first line | |
docker run \ | |
--privileged `: access to lots of device/low level things from container (trusted)` \ | |
--network=host \ # no docker interference on network (vs bridge, which remaps ports and adds overhead) | |
-v /mnt/sdb2/ros_shared/:/home/user/shared_with_host \ # shared folder with outside world. also, no indirect io | |
-v /dev/:/dev/\ # not sure this is necessary if we have --privilged | |
-v /tmp/.X11-unix/:/tmp/.X11-unix\ # communicate with host x windows via unix domain socktr (vs eg ssh) | |
-e DISPLAY=unix$DISPLAY \ # display env var for x windows (eg. RVIZ) | |
-e LINES \ # share the LINES env vars set from host with docker (otherwise tiny terminals) | |
-e COLUMNS \ # see LINES | |
--hostname='knightrider-docker' \ # helps distinguish container from outside world | |
--add-host="knightrider-docker:127.0.0.1" \ # custom missing from /etc/hosts otherwise | |
-d \ # run as daemon, otherwise the | |
-i \ # take STDIN input (not sure this is necessary for daemon) | |
$DOCKER_IMAGE \ # your own image you want to run | |
/bin/bash # somewhat arbitrary what runs here if we just want it in the background | |
# see what the name for the new container is (if it is running) | |
docker ps # shows running containers (there should be an entry if the above worked as expected) | |
docker ps -a # shows running and also stopped containers | |
# connect into running container instance and run a command (including an interactive terminal) | |
docker exec \ | |
-u user \ # otherwise will run as root | |
-e LINES \ # placing this both here and in docker run seem to be necessary, otherwise tiny terminal | |
-e COLUMNS \ # see LINES | |
-e DISPLAY=unix$DISPLAY # not sure this is necessary | |
-t \ # allocate tty. not sure what this is for. | |
-i \ # take stdin. useful for terminal... | |
$CONTAINER_NAME # from docker ps, needs to be running | |
/bin/bash # or your choice of program, if you want something else. | |
# within docker, can do exit, but daemon will keep running | |
docker stop $CONTAINER_NAME #can restart later if wanted | |
docker ps -a # find the container again if you don't remember | |
docker start $CONTAINER_NAME # resume where you started. | |
# if a container has some change you really want to keep and share with other people: | |
docker commit -m 'my message' $CONTAINER_NAME | |
# you get an image out | |
### within the container | |
# build the project (if needs to be rebuilt bc of new tools) | |
# may need to do more, see the knightrider repo scripts | |
cd ~/shared_with_host/software/knightrider/ | |
catkin_make -j 8 | |
# run the logging stuff (needs all devices connected) | |
ROS_BAG_PATH=~/shared_with_host/bagfiles/ roslaunch h_dblogging.launch veh:=white_prius | |
### vertica docker commands | |
#after a restart | |
docker ps -a # list all containers. see if one is named after vertica, eg vertica_container_0 | |
docker run vertica_container_0 | |
sudo docker exec vertica_container_0 /opt/vertica/bin/admintools -t start_db -d testid | |
# test things worked | |
vsql -d testid -U readonly_user -v schema=blob_schema | |
##### in case we need to start from image (eg, new image, new machine, or previous container lost somehow) | |
# start from image (you should only need this command after making a new image) | |
sudo docker run \ | |
--network=host `: will get us port 5433, and will remain steady. avoids overhead` \ | |
-v /nvme_drive/vertica_data:/vertica_data `: data is persisted to this folder, across container runs` \ | |
-v /nvme_drive/parquet_data:/nvme_drive/parquet_data `: allow loading parquet files easily` \ | |
-u dbadmin `: dbadmin is needed for most admintools commands` \ | |
-di `: daemon + stdin seems required to continue running` \ | |
--name=vertica_container_0 `: helps remember this is the vertica container. may want to increment number` \ | |
vertica-plus-tools `: image name` \ | |
/bin/bash `: placeholder` | |
## things to try next time: | |
# --restart= unless-stopped (will it start the |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment