Is it possible to force the docker provisioner to upgrade Docker to the latest release?
Hi @cazzerson
The version field documented here http://docs.vagrantup.com/v2/provisioning/docker.html specifies
The version of Docker to install. This defaults to "latest" and will install the latest version of Docker.
Does this answer your question?
Hi @sethvargo, thanks for the response. This seems to work well for the initial install but, as far as I can tell, once Vagrant has installed Docker on a VM, it won't upgrade it. I may be missing something here, though.
@cazzerson right, this is correct. But since containers are pretty portable, I would just destroy and re-create it.
@sethvargo We are distributing a vagrant config for external users, so it's difficult for us to keep them up to date if it requires them to periodically destroy their VM. Maybe we should just be installing Docker with our own provisioner.
@cazzerson I think that's a good stop-gap. I don't have quite enough context to decide if it's a good idea to always force the latest version as a top-level function in Vagrant, and I'd want to do some more thinking on that before making a decisions. But I think using a custom provisioner might be the best idea for now.
Thanks for your help. If you do return to this issue, I think it may be better to allow an upgrade rather than forcing it in every case, or even to request a later version than the one currently installed.
I stumbled upon this issue because of https://blog.docker.com/2015/07/new-apt-and-yum-repos/ there will be no new versions of docker in the old repository. Vagrant needs to adapt. Maybe I should open an issue for that?
However, I also agree with @cazzerson a supported update and upgrade path would be nice. Users of the provisioner should then explicitly mention the Docker version if they do not like to auto-upgrade.
@zimmski I would recommend opening an issue (or better yet, a PR!) to fix that new repo issue. Thanks!
@sethvargo @zimmski I'm playing around with a possible PR, but I'm running into some issues with the new distribution-oriented repos. The Docker install script has some platform detection to handle this. We could embed that fragment of this script, or just use the whole thing. Would you be concerned about pulling down the Docker installer?
Umm. I'm going to defer to the experts on that one...
@jfrazelle what do you think is the best way for Vagrant to install and manage the new Docker repos (Vagrant automatically installs Docker for users, but it appears to be broken with the new Docker apt/yum repos)?
Wellll I hate to say "curl pipe bash" _but_ the best way for cross distro installs is via the script at https://get.docker.com/
If you only need deb distros to work, you can add our new apt repo to your /etc/apt/sources.list and handle everything yourself.
Also you have time to change this, we will still be pushing the latest versions of docker to the old repo for 2 more releases.
The blog post doesn't say that because well people wouldn't update if we didn't scare em. ;)
When I get a sec, i will look into how it is working currently and can make a PR ;)
EDIT: couldn't wait, took a look, I can fix it ;)
@jfrazelle Thank you!! Can't wait!
@sethvargo @jfrazelle since I was already halfway there, I just opened a PR for discussion. Happy to change or close it.
oh nice awesome
On Fri, Aug 7, 2015 at 10:49 AM, Jason Casden [email protected]
wrote:
@sethvargo https://github.com/sethvargo @jfrazelle
https://github.com/jfrazelle since I was already halfway there, I just
opened a PR for discussion. Happy to change or close it.—
Reply to this email directly or view it on GitHub
https://github.com/mitchellh/vagrant/issues/6075#issuecomment-128776659.
Jessie Frazelle
4096R / D4C4 DD60 0D66 F65A 8EFC 511E 18F3 685C 0022 BFF3
pgp.mit.edu http://pgp.mit.edu/pks/lookup?op=get&search=0x18F3685C0022BFF3
@sethvargo Does the upgrade issue remain with https://github.com/mitchellh/vagrant/commit/bad4c2103d4cd56bb3ef57c76fc58e1360762389? Once Docker is installed it can't be upgraded with Vagrant?
@cazzerson the easiest way to _always_ have the latest release is to run a shell provisioner that always installs from get.docker.io. Since docker doesn't have a "version" option anymore, we can't always force an install.
We do have version pinning with =1.7.1* etc
Idk if that helps
Looks like it can't be passed to the get.docker.com script, but that may be on its way out? https://github.com/docker/docker/issues/13822
For those who like me need to install specific Docker version (which became impossible with docker provisioner after #6564), here is the script for Ubuntu guest OS. It should work ok with 15.04 and later. Probably it will work with earlier versions, though I have not tested. It will definitely not work with non-Ubuntu distros.
In Vagrantfile:
docker_version = "1.9.1"
config.vm.provision "install-docker",
type: "shell",
privileged: true,
path: "install-docker.sh",
args: [ docker_version ]
# instead of
# config.vm.provision "docker", version: docker_version
And here is install-docker.sh, which should be located in the same dir as Vagrantfile:
#!/usr/bin/env bash
set -e
DOCKER_VERSION=$1
echo "==> Installing Docker $DOCKER_VERSION"
IFS='=' read _ DISTRIB_CODENAME <<< $(grep </etc/lsb-release 'DISTRIB_CODENAME=')
if [ -z "$DISTRIB_CODENAME" ]; then
echo >&2 "Fatal: /etc/lsb-release doesn't contain DISTRIB_CODENAME variable"
exit 1
fi
echo -e "\n==> Ubuntu release codename: $DISTRIB_CODENAME"
apt-key adv \
--keyserver hkp://p80.pool.sks-keyservers.net:80 \
--recv-keys 58118E89F3A912897C070ADBF76221572C52609D
cat <<< "deb https://apt.dockerproject.org/repo ubuntu-$DISTRIB_CODENAME main" \
>/etc/apt/sources.list.d/docker.list
echo -e "\n==> Updating APT cache..."
apt-get update
echo -e "\n==> Installing kernel extensions..."
apt-get install -y linux-image-extra-$(uname -r)
echo -e "\n==> Installing Docker..."
apt-get install -y --force-yes "docker-engine=${DOCKER_VERSION}*"
echo -e "\n==> Checking installation..."
docker info >/dev/null || {
echo >&2 'Docker installation failed =('
exit 1
}
echo -e "\n==> All good!"
The same script can be used to upgrade and downgrade Docker, just modify docker_version variable in Vagrantfile and run vagrant provision --provision-with install-docker.
Most helpful comment
For those who like me need to install specific Docker version (which became impossible with
dockerprovisioner after #6564), here is the script for Ubuntu guest OS. It should work ok with 15.04 and later. Probably it will work with earlier versions, though I have not tested. It will definitely not work with non-Ubuntu distros.In
Vagrantfile:And here is
install-docker.sh, which should be located in the same dir asVagrantfile:The same script can be used to upgrade and downgrade Docker, just modify
docker_versionvariable inVagrantfileand runvagrant provision --provision-with install-docker.