[PYTHON] code-server online environment (5) Launch code-server on Docker

This is the 15th day article of Advent Calender on the 2019 code-server.

Continuing from the last time, I would like to launch EC2 Instance.

table of contents Local environment 1st day Online environment version 1st day Improve work environment

Online environment, day 2 Create a virtual network

Online environment 3rd day Launch an EC2 instance with Boto3

Online environment 4th day Try running Code-Server in the cloud

Online environment 5th day Launch code-server on Docker

Online environment, day 6 Let's automate

Online environment 7th day Deploy compute on git on EC2

... Online version .. Built with Coompose file

Online .. Try K8S

...

Demon remodeling

Introduction

Up to the last time, we have launched EC2 Instance with boto3 x python. Then I ran Code-Server.

This time, let's start Code-Server using Docker.

Create an EC2 Instance

From the last continuation

$ git clone https://github.com/kyorohiro/advent-2019-code-server.git
$ cd advent-2019-code-server/remote_cs04/
$ docker-compose build
$ docker-compose up -d

In your browser, open http://127.0.0.1:8443/.

Screen Shot 2019-12-24 at 0.39.23.png

On Terminal

Terminal


$ pip install -r requirements.txt
$ aws configure 
..
..

Create EC2Instance

$ python main.py --create

Get EC2 information

$ python main.py --get
>>>> i-0d1e7775a07bbb326
>>>> 
>>>> 3.112.18.33
>>>> ip-10-1-0-228.ap-northeast-1.compute.internal
>>>> 10.1.0.228
>>>> {'Code': 16, 'Name': 'running'}

Enter with SSH

$ chmod 600 advent-code-server.pem
$ ssh -i advent-code-server.pem [email protected]

Install Docker

I will create a Docker environment

On EC2

$ sudo apt-get update
$ sudo apt-get install -y docker.io

Docker's Hello World

$ sudo docker run hello-world
atest: Pulling from library/hello-world
1b930d010525: Pull complete 
Digest: sha256:4fe721ccc2e8dc7362278a29dc660d833570ec2682f4e4194f4ee23e415e1064
Status: Downloaded newer image for hello-world:latest

Hello from Docker!
This message shows that your installation appears to be working correctly.

Let's start Code-Server

$ mkdir -p  ${HOME}/.local/share/code-server/extensions
$ sudo docker run -it -p 0.0.0.0:8080:8080 -p0.0.0.0:8443:8443  codercom/code-server:v2 --cert
info  Server listening on https://0.0.0.0:8080
info    - Password is 86821ed9f02ef11d83e980da
info      - To use your own password, set the PASSWORD environment variable
info      - To disable use `--auth none`
info    - Using generated certificate and key for HTTPS
Screen Shot 2019-12-24 at 1.11.08.png Screen Shot 2019-12-24 at 1.06.50.png Screen Shot 2019-12-24 at 1.12.23.png

It's done !!

Let's delete

#logout from ec2 instance
$ exit

#local code-On the server
$ python main.py --delete

If you want to reuse it many times, please stop ec2 instance

next time

Let's automate the work that was done manually !!

code

https://github.com/kyorohiro/advent-2019-code-server/tree/master/remote_cs04

Recommended Posts

code-server online environment (5) Launch code-server on Docker
code-server online environment (4) Launch code-server on the EC2 instance
code-server online environment (1)
Launch code-server on alpine-linux
code-server online environment (7) Deploy compute on git on EC2
code-server online environment (6) Let's automate
code-server online environment (3) Launch an EC2 instance with Boto3
[Linux] Docker environment construction on Redhat
Created Ubuntu, Python, OpenCV environment on Docker
Launch environment with LineBot + Heroku + Docker + Python
Launch Flask application with Docker on Heroku
pykintone on Docker
Environment construction: GCP + Docker
Install docker on Fedora31
Launch Lambda on Boto3
How to build a Django (python) environment on docker
Install Docker on AWS
Launch Django on a Docker container with docker-compose up
Docker under proxy environment
Install Python 3.6 on Docker
Linux beginners create Ubuntu 16.04 environment on Docker (for Mac)-first half-
Create a VS Code + Docker development environment on a Linux VM
Introducing Kaggle's Docker Image on Windows to build an environment
Python environment construction procedure memo using Docker on Windows10 Home
Pyramid + mongodb environment on Mac
Anaconda environment construction on CentOS7
Prepare Chainer environment on Windows
Build Python environment on Windows
Docker + Django + React environment construction
Prepare python3 environment with Docker
Launch local server on mac
Django environment development on Windows 10
Build python environment on windows
[Tensorflow] Tensorflow environment construction on Windows 10
Run IPython Notebook on Docker
Install Docker on WSL Ubuntu 18.04
Linux environment construction (on WSL environment)
(Note) Notes on building TensorFlow + Flask + Nginx environment with Docker Compose