Skip to content

Commit

Permalink
Addressing crashing hosts when developing docker containers.
Browse files Browse the repository at this point in the history
  • Loading branch information
jonpugh committed Jan 5, 2020
1 parent f71120c commit cf1f72f
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ devmaster_id_rsa.pub
bin/*
~bin/devshop
!bin/branch-or-tag
!bin/docker-entrypoint
!bin/docker*
!bin/hosting-queue-runner
!bin/mysql-wait

Expand Down
3 changes: 3 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,9 @@ RUN chmod 766 $DEVSHOP_TESTS_ASSETS_PATH

RUN ansible --version

# Cleanup unwanted systemd files. See bin/docker-systemd-clean.
RUN docker-systemd-clean

# Remove Home Directory if desired so that devshop code is reinstalled.
RUN if [ $DEVSHOP_REBUILD_HOME ]; then rm -rf /var/aegir; fi

Expand Down
19 changes: 19 additions & 0 deletions bin/docker-systemd-clean
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
set -e

devshop-logo "Cleaning up SystemD"
echo "This should only be run inside a container with SystemD."
echo "See https://github.com/geerlingguy/docker-ubuntu1804-ansible/pull/12"

# @TODO: Make this multi-os, and determine if there are any unwanted side effects.
# The "ls" command should fail, breaking any build without this path.
ls -la /lib/systemd

find /lib/systemd/system/sysinit.target.wants/* ! -name systemd-tmpfiles-setup.service -delete;
rm -f /lib/systemd/system/multi-user.target.wants/*;
rm -f /etc/systemd/system/*.wants/*;
rm -f /lib/systemd/system/local-fs.target.wants/*;
rm -f /lib/systemd/system/sockets.target.wants/*udev*;
rm -f /lib/systemd/system/sockets.target.wants/*initctl*;
rm -f /lib/systemd/system/basic.target.wants/*;
rm -f /lib/systemd/system/anaconda.target.wants/*;find /lib/systemd/system/sysinit.target.wants/* ! -name systemd-tmpfiles-setup.service -delete;

0 comments on commit cf1f72f

Please sign in to comment.