Skip to content
Snippets Groups Projects
Commit 04f06109 authored by Alexander Werner's avatar Alexander Werner
Browse files

improve dns server hack

parent 878538f5
No related branches found
No related tags found
No related merge requests found
......@@ -90,8 +90,15 @@ if [ -z "${CONTAINER_NAME}" ]; then
CONTAINER_NAME=uw_${ROBOTNAME}_${USER}
fi
docker network create ${CONTAINER_NAME} || echo "Network already exists"
echo ${CONTAINER_NAME}
docker network ls | grep -q ${CONTAINER_NAME} || docker network create ${CONTAINER_NAME}
if [ -f /run/NetworkManager/resolv.conf ]; then
DOCKER_DNS_ARGS="--dns=$(cat /run/NetworkManager/resolv.conf | grep nameserver | sed -s "s/nameserver //" | head -n 1) "
elif [ -f /run/resolvconf/resolv.conf ]; then
DOCKER_DNS_ARGS="--dns=$(cat /run/resolvconf/resolv.conf | grep nameserver | sed -s "s/nameserver //" | head -n 1) "
else
DOCKER_DNS_ARGS="--dns=8.8.8.8"
fi
if ! docker container ps | grep -q ${CONTAINER_NAME}; then
echo "Starting new container with name: ${CONTAINER_NAME}"
$DOCKER_COMMAND run \
......@@ -105,9 +112,9 @@ if ! docker container ps | grep -q ${CONTAINER_NAME}; then
--cap-add=SYS_PTRACE \
--cap-add=SYS_NICE \
--cap-add=NET_ADMIN \
--dns=$(cat /run/systemd/resolve/resolv.conf | grep nameserver | sed -s "s/nameserver //" | head -n 1) \
--device /dev/bus/usb \
--device /dev/net \
$DOCKER_DNS_ARGS \
--network ${CONTAINER_NAME} \
$IMAGE_NAME
else
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment