Skip to content
Snippets Groups Projects
Select Git revision
  • 63c400cc6bd8cdd0eb3d0ced4371a485f4871e8b
  • main default
  • y3
  • y1
4 results

__init__.py

Blame
  • docker.bash 3.07 KiB
    # docker common commands
    alias dim="docker images"
    alias dpsa="docker ps -a"
    alias dps="docker ps"
    alias drm="docker rm"
    alias drmi="docker rmi"
    alias dsp="docker system prune --all"
    alias dimp="docker image prune"
    
    # Run container with rocker
    # usage: rundock {noetic, melodic} [{remodel_ws, odin_ws}] [cmd]
    # To share docker --volume /var/run/docker.sock:/var/run/docker.sock:ro
    function rundock() {
    	cd ~/ros/$1/$2;
    	rocker --home --ssh --git --user --nvidia --x11 --network host --name $1 devenv:$1 $3
    }
    
    # Execute container, move to workspace, and source SHELL
    # usage: dat {noetic, melodic} {remodel_ws, odin_ws}
    function dat() {
    	docker exec -it $1 bash -c "cd ~/ros/$1/$2 && $ext"
    }
    
    # Remove all stoped containers
    function drma() {
    	drm $(docker ps -a -f status=exited -q)
    }
    
    # Stop and remove
    function dsr() {
    	docker stop $1;
    	docker rm $1
    }
    
    # Remove all unused or dangling immages
    function drmui(){
    	drmi $(dim --filter "dangling=true" -q --no-trunc)
    }
    
    # Build docker image
    # usage: dockbuild {noetic, melodic}
    function dockbuild(){
    	cd ~/srcs/development_environment/dockerfiles;
    	docker build -t devenv:$1 --build-arg ROS_DISTRO=$1 -f devenv.Dockerfile .
    }
    
    # function runpythonsyntax(){
    # 	rocker --home --name python_syntax tecnalia-docker-dev.artifact.tecnalia.com/docker:git
    # }
    
    # function runremodel() {
    # 	rocker --x11 --nvidia --privileged --network=host --name remodel_docker --oyr-run-arg " -v iiwa_state_recorder:/home/remodel/iiwa_state_recorder -v /home/andres/test/remodel_shared:/home/remodel/remodel_shared" -- remodel_app:melodic bash -c "'roslaunch remodel_app remodel_app.launch use_sim:=true docker:=true skill_manager:=true collision_detector:=true ui:=true cad:=true joystick:=false'"
    # }
    
    # function docrun() {
    # 	rocker --nvidia --pulse --x11 --volume /dev/video0:/dev/video0 --privileged --oyr-run-arg " -v odin_robot_volume:/root/" --name odin_robot --network host odin_robot:melodic $1
    # }
    
    # function runodin() {
    # 	rocker --nvidia --pulse --x11 --privileged --volume /dev/video0:/dev/video0 --name odin_melodic --network host devenv:melodic $1
    # }
    
    #DOCKER
    alias dexec='f(){ docker exec -w /root/ --detach-keys="ctrl-@" -e DISPLAY=$DISPLAY -it $1  /bin/bash -c "terminator --no-dbus";  unset -f f; }; f'
    alias dexec_nt='f(){ docker exec --detach-keys="ctrl-@" -e DISPLAY=$DISPLAY -it $1  /bin/bash ;  unset -f f; }; f'
    alias dstart='f(){ docker start $1; dexec $1;  unset -f f; }; f'
    # Run using same X and .ssh folder
    alias drun='f(){ docker run -it -e DISPLAY=$DISPLAY --detach-keys="ctrl-@" -v /tmp/.X11-unix:/tmp/.X11-unix -v ~/.ssh:/root/.ssh:ro -v ~/docker_share/:/root/docker_share/ --net=host --name $2 $1; unset -f f; }; f'
    alias drun_nvidia='f(){ docker run -it --name $2 --privileged \
        --net=host \
        --env=NVIDIA_VISIBLE_DEVICES=all \
        --env=NVIDIA_DRIVER_CAPABILITIES=all \
        --env=DISPLAY \
        --env=QT_X11_NO_MITSHM=1 \
        -v /tmp/.X11-unix:/tmp/.X11-unix \
        --gpus all \
        --device /dev/snd \
        -e NVIDIA_VISIBLE_DEVICES=0 \
        --detach-keys="ctrl-@" \
        -v ~/.ssh:/root/.ssh:ro \
        -v ~/docker_share/:/root/docker_share/ \
        $1 /bin/bash; unset -f f; }; f'