Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: "docker-workshop-registry" box with pre-loaded images
Purpose: to decrease students' image download time and possible errors.
- Loading branch information
1 parent
adea18b
commit 9181994
Showing
13 changed files
with
279 additions
and
74 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Building a Docker Registry box with pre-loaded images | ||
=== | ||
|
||
|
||
## Name | ||
|
||
Official box name in Atlas (was: Vagrant Cloud): [`williamyeh/docker-workshop-registry`](https://atlas.hashicorp.com/williamyeh/boxes/docker-workshop-registry). | ||
|
||
|
||
|
||
## Purpose | ||
|
||
To build a Vagrant box, which: | ||
|
||
- derives from [`williamyeh/insecure-registry`](https://vagrantcloud.com/williamyeh/insecure-registry) box. | ||
- pre-loads Docker images listed in the `IMAGE-LIST` file from Docker Hub. | ||
|
||
|
||
|
||
## Build it on your own... | ||
|
||
### Prerequisite | ||
|
||
Install [`vagrant-hosts`](https://github.com/adrienthebo/vagrant-hosts) plugin: | ||
|
||
```bash | ||
vagrant plugin install vagrant-hosts | ||
``` | ||
|
||
### Build! | ||
|
||
|
||
```bash | ||
$ ./build.sh | ||
``` | ||
|
||
If everything is OK, you'll obtain a box file `docker-workshop-registry.box`. Feel free to place it on your local disk or cloud storage (Dropbox, S3, etc). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
Vagrant.require_version ">= 1.7.2" | ||
|
||
|
||
$script = <<PULL_SCRIPT | ||
# download "docker-mirror" tool | ||
curl -o /usr/local/bin/docker-mirror https://raw.githubusercontent.com/William-Yeh/docker-host-tools/master/docker-mirror | ||
chmod a+x /usr/local/bin/* | ||
# start the "docker-registry" app | ||
service docker-registry start | ||
# pull images from Docker Hub | ||
PRIVATE_DOCKER_REGISTRY=registry.com docker-mirror /vagrant/IMAGE-LIST | ||
PULL_SCRIPT | ||
|
||
|
||
|
||
Vagrant.configure(2) do |config| | ||
|
||
config.vm.box = "williamyeh/ubuntu-trusty64-docker" | ||
config.vm.box_version = ">= 1.5.0" | ||
|
||
# avoid possible request "vagrant@127.0.0.1's password:" when "up" and "ssh" | ||
config.ssh.password = "vagrant" | ||
|
||
|
||
config.vm.provision "hosts" do |hosts| | ||
hosts.add_host '127.0.0.1', ['registry.com'] | ||
end | ||
|
||
config.vm.provision "shell", path: "install-registry-app.sh" | ||
|
||
config.vm.provision "shell", inline: $script | ||
|
||
config.vm.provision "shell", path: "cleanup.sh" | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
#!/bin/bash | ||
|
||
readonly BOX_FILE=docker-workshop-registry.box | ||
#readonly BOX_FILE=output.box | ||
|
||
|
||
vagrant halt | ||
vagrant destroy --force | ||
|
||
vagrant up | ||
vagrant package --output $BOX_FILE | ||
|
||
vagrant destroy --force |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
#!/bin/bash | ||
|
||
# clean up docker's execution trace | ||
sudo docker kill docker-registry | ||
sudo docker rm `sudo docker ps --no-trunc -a -q` | ||
|
||
# clean "registry.com" host entry | ||
sed -i -e \ | ||
's/^.*registry.com$//' \ | ||
/etc/hosts | ||
|
||
|
||
sudo rm -f \ | ||
/var/log/messages \ | ||
/var/log/lastlog \ | ||
/var/log/auth.log \ | ||
/var/log/syslog \ | ||
/var/log/daemon.log \ | ||
/var/log/docker.log | ||
|
||
|
||
#---------------------------------------# | ||
# Vagrant-specific settings below | ||
# | ||
|
||
|
||
# zero out the free space to save space in the final image | ||
sudo dd if=/dev/zero of=/EMPTY bs=1M | ||
sudo rm -f /EMPTY | ||
|
||
|
||
rm -f /home/vagrant/.bash_history /var/mail/vagrant |
Oops, something went wrong.