-
Notifications
You must be signed in to change notification settings - Fork 379
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Option to start detached #36
Comments
Not needed anymore. I have a script that does the following:
I wanted the step 2. to not stop the script so it will continue to step 3: get container IP and add it to But I resolved that by switching step 3. and 2. and by providing a static IP to container. Here is the script: #!/bin/bash
[ -n "$(which x11docker)" ] \
|| { echo "x11docker is required"; exit 1; }
SCRIPT_DIR=$(dirname $(readlink -f "$0")) # /home/user/project/docker
PROJECT_DIR=$(dirname ${SCRIPT_DIR}) # /home/user/project
CMD=${@}
[ -n "${CMD}" ] \
|| { echo "Command is required"; exit 1; }
[ -n "$(docker images -q --filter=reference='my_image')" ] \
|| docker build -t my_image ${SCRIPT_DIR}
NETWORK=my_app
SUBNET='172.33.0.0/16'
IP='172.33.0.11'
HOST='project.dev'
[ -n "$(docker network ls -q --filter name=${NETWORK})" ] \
|| docker network create --subnet="${SUBNET}" ${NETWORK}
if grep -q "${HOST}" /etc/hosts; then
if [ "${IP}" != "$(grep "${HOST}" /etc/hosts | grep -o --regexp='^[0-9\.]\+')" ]; then
echo "Updating ${HOST} in /etc/hosts"
sudo sed -i "s/^.*\t\(${HOST}\)/${IP}\t\1/g" /etc/hosts
fi
else
echo "Adding ${HOST} in /etc/hosts"
echo "${IP} ${HOST}" | sudo tee -a /etc/hosts
fi
x11docker --hostdisplay --homedir ${HOME} --clipboard --stdout --stderr \
--cap-default --no-entrypoint \
-- "--cap-add=SYS_PTRACE \
--sysctl net.ipv4.ip_unprivileged_port_start=0 \
--workdir ${PROJECT_DIR} \
--network ${NETWORK} \
--hostname ${HOST} \
--ip ${IP}" \
my_image \
${CMD} |
x11docker already runs docker in detached mode. Alternativly, you can run x11docker in background with
You can parse Update: x11docker V3.9.8.1 shows the container ID on stdout like docker does in detached mode. With the container ID you can run
This syntax has also the effect to run x11docker in background like with
This does not take effect as x11docker always executes |
…-dbus-system (remove root-sh-shell in parent tree and enable no-new-privileges) Output of container ID on stdout (#36) Signed-off-by: mviereck <[email protected]>
Actually it works (even after this latest update)
Also
My FROM ubuntu:17.10
RUN apt-get update \
&& apt-get install -y \
wget tar git man nano htop curl \
libgtk2.0-0 libcanberra-gtk-module libxext-dev libxrender-dev libxtst-dev libxslt-dev dmz-cursor-theme \
libx11-xcb-dev libxss-dev gconf2 libnss3 libsecret-1-0 gnome-keyring libcap2-bin inotify-tools apgdiff \
&& (curl -sL https://deb.nodesource.com/setup_9.x | bash -) \
&& apt-get install -y \
build-essential nodejs \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*
ENV TINI_VERSION 0.17.0
ADD https://github.com/krallin/tini/releases/download/v${TINI_VERSION}/tini /tini
RUN chmod +x /tini
EXPOSE 443
ENTRYPOINT ["/tini", "--"]
CMD ["sleep", "infinity"] |
ok, |
I've added a new x11docker option |
Thank you! |
I tried docker run's
--detach
but it doesn't detachx11docker --hostdisplay -- "--detach --cap-add=SYS_PTRACE" my_image my-command.sh
Or tricks like adding
&
at the end of command,disown
,nohup
should work fine?The text was updated successfully, but these errors were encountered: