Saturday, July 20, 2019

[DOCKER ON AWS] How to install Docker on AWS + download tar image from aws


Sources

[Creating connection to AWS instance using PuTTy]
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/putty.html?icmpid=docs_ec2_console

[Running docker on aws] https://docs.aws.amazon.com/AmazonECS/latest/developerguide/docker-basics.html



  1. Launch a AWS instance
  2. Create and download new key pair
  3. Open PuttyGen
  4. Load the new key pair
  5. Generate and save the new private key pair
  6. Open Putty, copy the "ec2-user@csdjncs" into the Hostname tab as follows
     
       PuTTY configuration - Session
  7. In SSH -> Auth -> Click Browse and select the generated key
  8. Open the connection.

Install Docker

  1. Update the installed packages and package cache on your instance.
    sudo yum update -y
  2. Install the most recent Docker Community Edition package.
    sudo amazon-linux-extras install docker
  3. Start the Docker service.
    sudo service docker start
  4. Add the ec2-user to the docker group so you can execute Docker commands without using sudo.
    sudo usermod -a -G docker ec2-user
  5. Log out and log back in again to pick up the new docker group permissions. You can accomplish this by closing your current SSH terminal window and reconnecting to your instance in a new one. Your new SSH session will have the appropriate docker group permissions.
  6. Verify that the ec2-user can run Docker commands without sudo.
    docker info
    Note
    In some cases, you may need to reboot your instance to provide permissions for the ec2-user to access the Docker daemon. Try rebooting your instance if you see the following error:
    Cannot connect to the Docker daemon. Is the docker daemon running on this host?

Run the rstudio image

docker run -d -p 8787:8787 -e ROOT=TRUE -e PASSWORD=yourpasswordhere rocker/rstudio

Get the ip of the instance from the public IP entry

in the browser enter xxx.xxx.xxx.xxx:8787


Make sure to make the file on s3 public
Select file -> Actions -> make public



For launch scripts

#-- Linux AMI 2018.03
#!/bin/bash
yum update -y
yum-config-manager --enable rhui-REGION-rhel-server-extras
yum -y install docker
service docker start
usermod -a -G docker ec2-user
cd /home/ec2-user/
wget "https://abolfadl.s3.eu-central-1.amazonaws.com/docker/images/mabolfadl_rstudio_libs.tar"

#-- After opening a shell with putty
docker load < mabolfadl_rstudio_libs.tar
docker run -p 8787:8787 -e PASSWORD=asd123 $(docker images -q)

#-- Ubuntu
sudo yum update -y
sudo amazon-linux-extras install docker
sudo service docker start
sudo usermod -a -G docker ec2-user
wget "https://abolfadl.s3.eu-central-1.amazonaws.com/docker/images/mabolfadl_rstudio_libs.tar"

#-- After opening a shell with putty
docker load < mabolfadl_rstudio_libs.tar
docker run -p 8787:8787 -e PASSWORD=asd123 $(docker images -q)





No comments:

Post a Comment

Loud fan of desktop

 Upon restart the fan of the desktop got loud again. I cleaned the desktop from the dust but it was still loud (Lower than the first sound) ...