User data to install and run Docker in an Ubuntu AWS instance

by Marc Cortada 21/05/2017

This snippet is based in Ubuntu 16.04.2 version.

After running this script docker will be installed in your Amazon Web Services instance.

Some attention points:

  • These commands are executed in background when the instance is running and could take some time to finish. If you login just when the instance is available the installation could be not ready yet.
#!/bin/bash

apt-get -y install \
  apt-transport-https \
  ca-certificates \
  curl

curl -fsSL https://download.docker.com/linux/ubuntu/gpg | apt-key add -

add-apt-repository \
       "deb [arch=amd64] https://download.docker.com/linux/ubuntu \
       $(lsb_release -cs) \
       stable"

apt-get update

apt-get -y install docker-ce
When the machine is running and the execution is finished you can run:
docker run hello-world
This snippet is based in the info available here: https://store.docker.com/editions/community/docker-ce-server-ubuntu

Tags:

Categorías: Amazon Web Services (AWS) | AWS User Data | Developing and programming | Docker

Entradas por mes