How to migrate a web application created in a local docker environment to AWS

background

Since I was making a web application in a local environment, I moved to a server on AWS. I had never set up a server on AWS, so I tried it while having an expert teach me. I'll forget it, so I'll leave the steps up to running docker on the server for myself in the future.

Main story

Here is the rough work procedure.

  1. Set up an EC2 instance on AWS
  2. Install docker in the server you set up
  3. Clone the application from gitlab

Actual steps

The actual procedure was as follows. However, this time, I will omit how to create an EC2 instance.

Until entering the server

  1. Create an EC2 instance of AWS (details may be written in the future) When 2.1 is created, a file with .pem will be created, so save this as~ / .ssh /.
  2. There is an IP address on the AWS EC2 page, so ssh it. I tried ssh xx.xxx.xx.xxx but couldn't.
  3. I gave it a user name. I tried ssh [email protected] but couldn't.
  4. When you want to see the error log ssh -v [email protected]
  5. ssh -i ~ / .ssh / xxx.pem [email protected] and entered with the xxx.pem command. You can enter ubuntu using the key xxx.pem. It seems to be a command.

At the server

  1. I want to clone the repository in gitlab to the server side with ssh. I can't clone suddenly, so first make a key pair with ssh-keygen. You will be asked three times, but if nothing else, just press Enter three times.
  2. There should be a key called .ssh / id_rsa.pub, so copy the contents and paste it in the place where you enter the public key on gitlab (it should have been set).
  3. Install docker on the server. Do sudo apt update first and sudo apt install docker.io.
  4. Check if you can docker ps. I didn't have permission, so I cast the spell sudo usermod -aG docker $ USER.
  5. Log out, log in again, and docker ps to confirm.
  6. Install docker-compose with sudo apt install docker-compose.
  7. docker-compose up should start it. If you want to drop it, just do docker-compose down or docker-compose stop. By the way, if you want to run it in the background, you can do it with docker-compose up -d.

Summary

I migrated a web application running in a local docker environment to AWS. I talked about the contents until entering the AWS server and the contents until entering the server and running docker. Probably there are other ways, so please refer to it.

Recommended Posts

How to migrate a web application created in a local docker environment to AWS
How to install Docker in the local environment of an existing Rails application [Rails 6 / MySQL 8]
I tried to build a Firebase application development environment with Docker in 2020
How to create a Java environment in just 3 seconds
How to deploy to Heroku from a local docker image
[AWS] How to automatically deploy a Web application created with Rails 6 to ECR / ECS using CircleCI ① Preparation [Container deployment]
How to install Web application for each language in Nginx
I tried to implement a buggy web application in Kotlin
[Docker context] ~ How to access docker in remote environment from VScode ~
How to deploy a Rails application on AWS (article summary)
Connect to AWS RDS from your local PC Docker environment
How to automatically operate a screen created in Java on Windows
How to publish an application using AWS (3) EC2 instance environment construction
How to create a web server on an EC2 instance on AWS
How to build an environment with Docker, which is the minimum required to start a Rails application
I want to develop a web application!
Create a web environment quickly using Docker
How to reflect seeds.rb in production environment
How to insert a video in Rails
Web application scheduled to be created (editing)
How to use Docker in VSCode DevContainer
How to use environment variables in RubyOnRails
How to publish a library in jCenter
Understand in 5 minutes !! How to use Docker
Java application development environment created in VM environment
How to build Rails 6 environment with Docker
How to build a Ruby on Rails environment using Docker (for Docker beginners)
How to develop from VScode in a remote destination environment or a remote destination container environment
How to execute with commands of normal development language in Docker development environment
[Docker] How to create a virtual environment for Rails and Nuxt.js apps
How to build a Ruby on Rails development environment with Docker (Rails 6.x)
[AWS CLI] Switch roles to get a Docker image in another account
How to build a Ruby on Rails development environment with Docker (Rails 5.x)
Create a java web application development environment with docker for mac part2
How to start a Docker container with a volume mounted in a batch file
How to apply Rails environment variables to Docker container (aws :: Sigv4 :: Errors solution)
How to check the logs in the Docker container
How to deploy a container on AWS Lambda
How to get a heapdump from a Docker container
I built a Java EE environment on AWS and tried running a web application
Sign in to a Spring Boot web application on the Microsoft ID platform
How to run a djUnit task in Ant
How to add a classpath in Spring Boot
How to update pre-built files in docker container
How to create a theme in Liferay 7 / DXP
How to implement a like feature in Rails
How to easily create a pull-down in Rails
Docker × Laravel HTTPS (SSL) communication in local environment
How to set environment variables in the properties file of Spring boot application
[Rails] How to build an environment with Docker
How to make a follow function in Rails
How to build a Pytorch environment on Ubuntu
[Rails] How to use PostgreSQL in Vagrant environment
How to automatically generate a constructor in Eclipse
Temporarily move Docker environment from Mac to AWS
[Rails] [Docker] Copy and paste is OK! How to build a Rails development environment with Docker
[Personal application work memo] How to display a bar graph and a line graph in one graph
[Docker] How to update using a container on Heroku and how to deal with Migrate Error
How to quit Docker for Mac and build a Docker development environment with Ubuntu + Vagrant
A story that stumbled when deploying a web application created with Spring Boot to EC2
Docker command to create Rails project with a single blow in environment without Ruby