-
Notifications
You must be signed in to change notification settings - Fork 1
/
run_in_docker.sh
executable file
·27 lines (20 loc) · 1000 Bytes
/
run_in_docker.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/bin/bash
DOCKERFILE=Dockerfile.ubuntu.executable
IMAGE_NAME=startim_executable
CONTAINER_NAME=start_container_executable
# Adding docker to the host X-server to turn on the graphical env
xhost +local:docker
# Build the Docker image
docker build -f $DOCKERFILE -t $IMAGE_NAME .
# Rebuild container from scratch each time. (2>/dev/null || true) avoid failure if in we have error in `stderr`
docker stop $CONTAINER_NAME 2>/dev/null || true
docker rm $CONTAINER_NAME 2>/dev/null || true
# Run the Docker container with graphical environment support
docker run -it --name $CONTAINER_NAME -e DISPLAY=$DISPLAY -v /tmp/.X11-unix:/tmp/.X11-unix -v /dev/dri:/dev/dri $IMAGE_NAME
# To remove this image and container execute the following commands
# docker rm $CONTAINER_NAME 2>/dev/null || true
# docker rmi $IMAGE_NAME 2>/dev/null || true
# To push image to the dockerhub:
# docker login
# docker tag $IMAGE_NAME <dockerhub_user>/<image_name>:<tag>
# docker push <dockerhub_user>/<image_name>:<tag>