Skip to content

Instantly share code, notes, and snippets.

@bruth
Last active January 27, 2021 17:37

Revisions

  1. bruth revised this gist Apr 26, 2016. 2 changed files with 0 additions and 0 deletions.
    File renamed without changes.
    File renamed without changes.
  2. bruth revised this gist Apr 26, 2016. 2 changed files with 2 additions and 2 deletions.
    2 changes: 1 addition & 1 deletion install-docker-compose.sh
    Original file line number Diff line number Diff line change
    @@ -5,7 +5,7 @@
    # an error will occur with running `docker-compose`. Rather than changing how /tmp
    # is mounted, this script creates a wrapper that sets an alternate `TMPDIR` variable.

    COMPOSE_VERSION=1.6.0
    COMPOSE_VERSION=1.7.0
    TMP_DIR=/data/tmp

    mkdir -p $TMP_DIR
    2 changes: 1 addition & 1 deletion setup-rhel7-docker-repo.sh
    Original file line number Diff line number Diff line change
    @@ -4,7 +4,7 @@
    # See https://docs.docker.com/engine/articles/configuring/#centos-red-hat-enterprise-linux-fedora

    # Configuration.
    ENGINE_VERSION=1.10.0
    ENGINE_VERSION=1.11.0
    DATA_DIR=/data/docker

    mkdir -p $DATA_DIR
  3. bruth revised this gist Mar 17, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions install-docker-compose.sh
    Original file line number Diff line number Diff line change
    @@ -9,6 +9,8 @@ COMPOSE_VERSION=1.6.0
    TMP_DIR=/data/tmp

    mkdir -p $TMP_DIR
    chgrp docker $TMP_DIR
    chmod g+w $TMP_DIR

    # Download release.
    curl -L "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose-real
  4. bruth revised this gist Feb 17, 2016. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions install-docker-compose.sh
    Original file line number Diff line number Diff line change
    @@ -20,5 +20,6 @@ cat << EOF > /usr/local/bin/docker-compose
    TMPDIR="$TMP_DIR" /usr/local/bin/docker-compose-real \$@
    EOF

    chown root:docker /usr/local/bin/{docker-compose,docker-compose-real}
    chmod +x /usr/local/bin/docker-compose-real
    chmod +x /usr/local/bin/docker-compose
  5. bruth revised this gist Feb 9, 2016. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion add-docker-user.sh
    Original file line number Diff line number Diff line change
    @@ -1,2 +1,2 @@
    #!/bin/bash
    /usr/sbin/usermod -aG docker `whoami`
    /usr/sbin/usermod -aG docker <user>
  6. bruth revised this gist Feb 9, 2016. 1 changed file with 2 additions and 0 deletions.
    2 changes: 2 additions & 0 deletions add-docker-user.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,2 @@
    #!/bin/bash
    /usr/sbin/usermod -aG docker `whoami`
  7. bruth revised this gist Feb 9, 2016. 2 changed files with 26 additions and 21 deletions.
    24 changes: 24 additions & 0 deletions install-docker-compose.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,24 @@
    #!/bin/bash
    # Install Docker Compose
    # This script sets installs Compose with an alternate TMPDIR. Compose requires exec
    # privileges in the /tmp directory, however if /tmp is mounted with `noexec` then
    # an error will occur with running `docker-compose`. Rather than changing how /tmp
    # is mounted, this script creates a wrapper that sets an alternate `TMPDIR` variable.

    COMPOSE_VERSION=1.6.0
    TMP_DIR=/data/tmp

    mkdir -p $TMP_DIR

    # Download release.
    curl -L "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose-real

    # Create wrapper.
    cat << EOF > /usr/local/bin/docker-compose
    #!/bin/bash
    TMPDIR="$TMP_DIR" /usr/local/bin/docker-compose-real \$@
    EOF

    chmod +x /usr/local/bin/docker-compose-real
    chmod +x /usr/local/bin/docker-compose
    23 changes: 2 additions & 21 deletions setup-rhel7-docker-repo.sh
    Original file line number Diff line number Diff line change
    @@ -1,18 +1,12 @@
    #!/bin/bash
    # Docker repo on RHEL 7
    # This script sets up the official Docker YUM repo on a RHEL 7 machine.
    # Run as root.
    # See https://docs.docker.com/engine/articles/configuring/#centos-red-hat-enterprise-linux-fedora

    # Target versions
    # Configuration.
    ENGINE_VERSION=1.10.0
    COMPOSE_VERSION=1.6.0

    # Data and tmp directories.
    DATA_DIR=/data/docker
    TMP_DIR=/data/tmp

    mkdir -p $TMP_DIR
    mkdir -p $DATA_DIR

    # Remove existing Docker
    @@ -71,17 +65,4 @@ systemctl enable docker
    systemctl start docker

    # Check status
    systemctl status docker

    # Docker Compose
    curl -L "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose-real

    # Wrapper for noexec /tmp file system.
    cat << EOF > /usr/local/bin/docker-compose
    #!/bin/bash
    TMPDIR="$TMP_DIR" /usr/local/bin/docker-compose-real \$@
    EOF

    chmod +x /usr/local/bin/docker-compose-real
    chmod +x /usr/local/bin/docker-compose
    systemctl status -l docker
  8. bruth renamed this gist Feb 9, 2016. 1 changed file with 0 additions and 0 deletions.
    File renamed without changes.
  9. bruth revised this gist Feb 9, 2016. 1 changed file with 21 additions and 5 deletions.
    26 changes: 21 additions & 5 deletions setup.sh
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,15 @@
    # See https://docs.docker.com/engine/articles/configuring/#centos-red-hat-enterprise-linux-fedora

    # Target versions
    DOCKER_ENGINE_VERSION=1.10.0
    DOCKER_COMPOSE_VERSION=1.6.0
    ENGINE_VERSION=1.10.0
    COMPOSE_VERSION=1.6.0

    # Data and tmp directories.
    DATA_DIR=/data/docker
    TMP_DIR=/data/tmp

    mkdir -p $TMP_DIR
    mkdir -p $DATA_DIR

    # Remove existing Docker
    yum remove -yt docker docker-selinux
    @@ -22,7 +29,7 @@ gpgkey=https://yum.dockerproject.org/gpg
    EOF

    # Install docker-engine
    yum install -y "docker-engine-$DOCKER_ENGINE_VERSION"
    yum install -y "docker-engine-$ENGINE_VERSION"

    # Add environment file. Update to match the particular host. Note the renamed
    # argument from --add-registry to --registry-mirror. See https://access.redhat.com/articles/881893
    @@ -31,7 +38,7 @@ cat << EOF > /etc/sysconfig/docker
    DOCKER_CERT_PATH=/etc/docker
    OPTIONS="--selinux-enabled --graph=/data/docker --host=unix:///var/run/docker.sock --group=docker --registry-mirror=https://registry.access.redhat.com"
    OPTIONS="--selinux-enabled --graph=$DATA_DIR --host=unix:///var/run/docker.sock --group=docker --registry-mirror=https://registry.access.redhat.com"
    EOF

    # Ensure the system directory is created.
    @@ -67,5 +74,14 @@ systemctl start docker
    systemctl status docker

    # Docker Compose
    curl -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose
    curl -L "https://github.com/docker/compose/releases/download/$COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose-real

    # Wrapper for noexec /tmp file system.
    cat << EOF > /usr/local/bin/docker-compose
    #!/bin/bash
    TMPDIR="$TMP_DIR" /usr/local/bin/docker-compose-real \$@
    EOF

    chmod +x /usr/local/bin/docker-compose-real
    chmod +x /usr/local/bin/docker-compose
  10. bruth revised this gist Feb 9, 2016. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions setup.sh
    Original file line number Diff line number Diff line change
    @@ -5,8 +5,8 @@
    # See https://docs.docker.com/engine/articles/configuring/#centos-red-hat-enterprise-linux-fedora

    # Target versions
    DOCKER_ENGINE_VERSION=1.10
    DOCKER_COMPOSE_VERSION=1.6
    DOCKER_ENGINE_VERSION=1.10.0
    DOCKER_COMPOSE_VERSION=1.6.0

    # Remove existing Docker
    yum remove -yt docker docker-selinux
    @@ -31,7 +31,7 @@ cat << EOF > /etc/sysconfig/docker
    DOCKER_CERT_PATH=/etc/docker
    OPTIONS="--selinux-enabled --graph=/data/docker --host=unix:///var/run/docker.sock --group=dockerroot --registry-mirror=https://registry.access.redhat.com"
    OPTIONS="--selinux-enabled --graph=/data/docker --host=unix:///var/run/docker.sock --group=docker --registry-mirror=https://registry.access.redhat.com"
    EOF

    # Ensure the system directory is created.
  11. bruth created this gist Feb 9, 2016.
    71 changes: 71 additions & 0 deletions setup.sh
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,71 @@
    #!/bin/bash
    # Docker repo on RHEL 7
    # This script sets up the official Docker YUM repo on a RHEL 7 machine.
    # Run as root.
    # See https://docs.docker.com/engine/articles/configuring/#centos-red-hat-enterprise-linux-fedora

    # Target versions
    DOCKER_ENGINE_VERSION=1.10
    DOCKER_COMPOSE_VERSION=1.6

    # Remove existing Docker
    yum remove -yt docker docker-selinux

    # Install official Docker yum repo. See http://docs.docker.com/engine/installation/rhel/
    cat << EOF > /etc/yum.repos.d/docker.repo
    [Docker]
    name=Docker Repository
    baseurl=https://yum.dockerproject.org/repo/main/centos/7
    enabled=1
    gpgcheck=1
    gpgkey=https://yum.dockerproject.org/gpg
    EOF

    # Install docker-engine
    yum install -y "docker-engine-$DOCKER_ENGINE_VERSION"

    # Add environment file. Update to match the particular host. Note the renamed
    # argument from --add-registry to --registry-mirror. See https://access.redhat.com/articles/881893
    cat << EOF > /etc/sysconfig/docker
    # /etc/sysconfig/docker
    DOCKER_CERT_PATH=/etc/docker
    OPTIONS="--selinux-enabled --graph=/data/docker --host=unix:///var/run/docker.sock --group=dockerroot --registry-mirror=https://registry.access.redhat.com"
    EOF

    # Ensure the system directory is created.
    mkdir -p /etc/systemd/system

    # Override config since ExecStart cannot be extended (per the systemd docs).
    cat << EOF > /etc/systemd/system/docker.service
    [Unit]
    Description=Docker Application Container Engine
    Documentation=https://docs.docker.com
    After=network.target docker.socket
    Requires=docker.socket
    [Service]
    Type=notify
    EnvironmentFile=/etc/sysconfig/docker
    ExecStart=/usr/bin/docker daemon \$OPTIONS
    MountFlags=slave
    LimitNOFILE=1048576
    LimitNPROC=1048576
    LimitCORE=infinity
    [Install]
    WantedBy=multi-user.target
    EOF

    # Reload config and start the daemon
    systemctl daemon-reload
    systemctl enable docker
    systemctl start docker

    # Check status
    systemctl status docker

    # Docker Compose
    curl -L "https://github.com/docker/compose/releases/download/$DOCKER_COMPOSE_VERSION/docker-compose-$(uname -s)-$(uname -m)" > /usr/local/bin/docker-compose
    chmod +x /usr/local/bin/docker-compose