Skip to content

Instantly share code, notes, and snippets.

@mopemope
Created May 13, 2014 08:34
Show Gist options
  • Save mopemope/8950df8bef335bf56dd2 to your computer and use it in GitHub Desktop.
Save mopemope/8950df8bef335bf56dd2 to your computer and use it in GitHub Desktop.
run systemd-nspawn docker container
core@coreos-local ~ $ ./nspawn-container jmatis/tomcat7 "/opt/start-watch-tomcat.sh"
Pulling repository jmatis/tomcat7
b3dfa5e5f738: Download complete
511136ea3c5a: Download complete
5e66087f3ffe: Download complete
4d26dd3ebc1c: Download complete
d4010efcfd86: Download complete
99ec81b80c55: Download complete
c17d434dd941: Download complete
180579a76826: Download complete
70b292be7c3d: Download complete
e2419f30daad: Download complete
c2ca823ebbc4: Download complete
445f2398cbc4: Download complete
f85f73dd1b9d: Download complete
c4f75cb9ab93: Download complete
b58adeff522e: Download complete
befa96e5fe82: Download complete
6f9ee090a12e: Download complete
d3f4260c8105: Download complete
5b3f2ee54eab: Download complete
356083970ded: Download complete
eec797b8851d: Download complete
2ece8bcfa438: Download complete
746d3edfc36d: Download complete
core-jmatis_tomcat7
Spawning container core-jmatis_tomcat7 on /var/lib/toolbox/core-jmatis_tomcat7. Press ^] three times within 1s to abort execution.
/etc/localtime is not a symlink, not updating container timezone.
Using CATALINA_BASE: /opt/tomcat/
Using CATALINA_HOME: /opt/tomcat/
Using CATALINA_TMPDIR: /opt/tomcat//temp
Using JRE_HOME: /opt/java/
Using CLASSPATH: /opt/tomcat//bin/bootstrap.jar:/opt/tomcat//bin/tomcat-juli.jar
Tomcat started.
May 13, 2014 8:33:36 AM org.apache.catalina.core.AprLifecycleListener init
INFO: The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: /usr/java/packages/lib/amd64:/usr/lib64:/lib64:/lib:/usr/lib
May 13, 2014 8:33:36 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["http-bio-8080"]
May 13, 2014 8:33:36 AM org.apache.coyote.AbstractProtocol init
INFO: Initializing ProtocolHandler ["ajp-bio-8009"]
May 13, 2014 8:33:36 AM org.apache.catalina.startup.Catalina load
INFO: Initialization processed in 1338 ms
May 13, 2014 8:33:36 AM org.apache.catalina.core.StandardService startInternal
INFO: Starting service Catalina
May 13, 2014 8:33:36 AM org.apache.catalina.core.StandardEngine startInternal
INFO: Starting Servlet Engine: Apache Tomcat/7.0.53
May 13, 2014 8:33:36 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/apache-tomcat-7.0.53/webapps/ROOT
May 13, 2014 8:33:37 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/apache-tomcat-7.0.53/webapps/docs
May 13, 2014 8:33:38 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/apache-tomcat-7.0.53/webapps/examples
May 13, 2014 8:33:39 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/apache-tomcat-7.0.53/webapps/host-manager
May 13, 2014 8:33:39 AM org.apache.catalina.startup.HostConfig deployDirectory
INFO: Deploying web application directory /opt/apache-tomcat-7.0.53/webapps/manager
May 13, 2014 8:33:39 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["http-bio-8080"]
May 13, 2014 8:33:39 AM org.apache.coyote.AbstractProtocol start
INFO: Starting ProtocolHandler ["ajp-bio-8009"]
May 13, 2014 8:33:39 AM org.apache.catalina.startup.Catalina start
INFO: Server startup in 2783 ms
#!/bin/bash
TOOLBOX_DOCKER_IMAGE=$1
TOOLBOX_USER=root
toolboxrc="${HOME}"/.toolboxrc
if [ -f "${toolboxrc}" ]; then
source "${toolboxrc}"
fi
machinename=$(echo "${USER}-${TOOLBOX_DOCKER_IMAGE}" | sed -r 's/[^a-zA-Z0-9_.-]/_/g')
machinepath="/var/lib/toolbox/${machinename}"
if [ ! -d ${machinepath} ] || systemctl is-failed ${machinename} ; then
sudo mkdir -p "${machinepath}"
sudo chown ${USER}: "${machinepath}"
docker pull "${TOOLBOX_DOCKER_IMAGE}"
docker run --name=${machinename} "${TOOLBOX_DOCKER_IMAGE}" /bin/true
docker export ${machinename} | sudo tar -x -C "${machinepath}" -f -
docker rm ${machinename}
sudo touch "${machinepath}"/etc/os-release
fi
sudo systemd-nspawn -D "${machinepath}" --share-system --bind=/:/media/root --bind=/usr:/media/root/usr --user="${TOOLBOX_USER}" $2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment