Build an environment with Docker on AWS

3 ways to send a container to AWS

-Use the Docker registry (Docker hub) ・ Send Dockerfile ・ Send Docker image as tar

Log in to the host EC2 with SSH

Access with SSH when using the shell. If you log in with SSH, you can install Docker on your AWS instance.

SSH ・ ・ ・ secure shell Launch a shell to secure

ssh -i xx.pem username@hostname

xx.pem ・ ・ ・ Key file downloaded when the server was set up -i ・ ・ ・ Option to specify the key file

Example) ssh -i mydocker.pem ubuntu@ec2 ・ ・ ・ .amazonaws.com

Install Docker on your AWS instance

-Access the server with SSH.  ssh -i xx.pem username@hostname ・ Update the package  sudo apt-get update ・ Install docker  sudo apt-get install docker.io

※sudo gpasswd -a ubuntu docker By creating a group called docker and putting ubuntu in it, people who belong to the group can use docker. When using docker on ubuntu server, basically do it (It will be possible to execute without sudo)

Create a container by sending a Docker image as a tar

Send the Docker image as a tar.

Convert to tar file

docker save image ID> arbitrary file name.tar docker save fd867gy7fg > myimage.tar

Access AWS with sftp

Files can be transferred by accessing with sftp.

sftp ・ ・ ・ Secure File Transfer Protocol

sftp -i xx.pem username@hostname Example) ssh -i mydocker.pem ubuntu@ec2 ・ ・ ・ .amazonaws.com

Forward

・ Put local / path [remote / path] put temp_folder/myimage.tar /home/ubuntu Send local files to remote server (EC2)

・ Get local / path [remote / path] Fetch files from a remote server (EC2).

Revert to Docker image from .tar

Access AWS with ssh and restore the image with docker load. · Ssh -i xx.pem username @ hostname -Docker load <filename.tar -Make it a container with docker run.

Example) docker load < myimage.tar

Create a container by transferring Dockerfile

-Access with sftp and transfer the docker file.  sftp -i xxx.pem ubuntu@[hostname]  put local/path [remote/path]

・ Access with ssh, build and create a container  ssh -i xxx.pem ubuntu@[hostname] (Create a new folder, create a build context and put the Dockerfile there)  docker build .

Finally

This article is a transcript of udemy's docker course (https://www.udemy.com/share/103aTRAEMfeVhaTXoB/) by Kame-san (https://twitter.com/usdatascientist?s=21).

Kame-san's blog (https://datawokagaku.com/docker_lecture/)

Recommended Posts

Build an environment with Docker on AWS
Build an Ultra96v2 development environment on Docker 1
Environment construction command memo with Docker on AWS
Build a Laravel environment on an AWS instance
Build docker environment with WSL
[Rails] How to build an environment with Docker
[First team development ②] Build an environment with Docker
Build an environment of Ruby2.7.x + Rails6.0.x + MySQL8.0.x with Docker
Build WordPress environment with Docker (Local) and AWS (Production)
Build Couchbase local environment with Docker
Build PlantUML environment with VSCode + Docker
Build environment with vue.js + rails + docker
Build Rails environment with Docker Compose
Build Unity development environment on docker
Build docker + laravel environment with laradock
Build a PureScript development environment with Docker
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (5)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (6)
Build Java 8 development environment on AWS Cloud9
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (3)
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (2)
Build a Wordpress development environment with Docker
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (1)
Build Redmine code reading environment on Docker
[Rails AWS Docker] Build an existing Ruby on Rails + MySQL application with Docker and deploy it on AWS (4)
Try the Docker environment on AWS ECS
Build TensorFlow operation check environment with Docker
How to build Rails 6 environment with Docker
Build an ASP.net Core Web API environment on Docker (VSCode) Part 1
Build an ASP.NET Core Web API environment on Docker (VSCode) Part 2
Build a Laravel / Docker environment with VSCode devcontainer
Build a WordPress development environment quickly with Docker
Build an E2E test environment with Selenium (Java)
[Ruby on Rails] Let's build an environment on mac
Build mecab (NEologd dictionary) environment with Docker (ubuntu)
Build debug environment on container --Build local development environment for Rails tutorial with Docker-
Build an environment of "API development + API verification using Swagger UI" with Docker
Build a development environment on AWS EC2 with CentOS7 + Nginx + pm2 + Nuxt.js
Pytorch execution environment with Docker
Memo to build a Servlet environment on AWS EC2
Build Java development environment with VS Code on Mac
Build a Ruby on Rails development environment on AWS Cloud9
Building an environment for WordPress, MySQL and phpMyAdmin with Docker Compose on EC2
How to build docker environment with Gradle for intelliJ
Easily build a Vue.js environment with Docker + Vue CLI
[Note] Build a Python3 environment with Docker in EC2
[Error resolution] Occurs when trying to build an environment for spring with docker
Install docker on AWS EC2
Build Java development environment with WSL2 Docker VS Code
Build AWS Lambda with Quarkus
Build an Android image for Orange Pi 4 with Docker
React environment construction with Docker
Build DynamoDB local with Docker
I tried to build an environment using Docker (beginner)
[Amateur remarks] Build multiple WordPress on AWS using Docker Compose
Create an AWS IoT EduKit development environment with Ubuntu 20.04 + VirtualBox 6.1
How to build [TypeScript + Vue + Express + MySQL] environment with Docker ~ Express ~
Build a CentOS 8 virtual environment on your Mac with VirtualBox
How to build Rails, Postgres, ElasticSearch development environment with Docker
Build mate desktop environment on ec2 with terraform (Ubuntu 20.04LTS)
Build a Node-RED environment with Docker to move and understand