[Participation] Creating a Docker container that distributes Markdown as HTML in Apache / Pandoc --AWS container

The other day I introduced a Docker container that incorporates Apache and Pandoc. I introduced the case where the Markdown source is obtained from the local folder of the container host and the two versions that are obtained remotely.

-Local version -Remote version

In this article, I ran the remote version on Amazon ECS (Elastic Container Service), one of the Docker container services provided by the public cloud, so I will explain the procedure.

AWS ECS

There are different types of Amazon Docker container services.

Of these, the ECS used this time configures a cluster of containers using AWS virtual machines (EC2 instances), and executes a service that collects Docker containers called tasks.

The following is a state of running a service containing one task in a cluster composed of one EC2 instance. The Docker image used is a remote version registered with Docker Hub.

When using AWS services, you can either use the web console or the command line from the terminal where the AWS CLI is installed. The following used the console.

If you do the same, do the following:

--Create an AWS account (most services are free for one year) → Sign up --Create IAM user (because it is better to create a console user different from the root user of the account)

Enter the container service

Log in to the AWS console

→ https://account-id.signin.aws.amazon.com/console/

Select the ECS service and create the following in order.

--Task --Docker container allocation --Cluster --Creating an EC2 instance --Service --Specify a task

I have made all selections by default except those shown below. I will mainly explain the parts that needed to be specified or changed.

Creating a task

1-task-create

--Select "EC2" as the container storage location (there is another Fargate) --Name the task --Name the container --Specify an image Since the default image acquisition source is Docker Hub, simply specify "kobucom / pandoc: remote1" --Cluster to container port mapping TCP:80 → 80

2-task-create

Creating a cluster

3-cluster-create

--Select "EC2 Linux + Networking" as the cluster type --Name the cluster --Choose the type and number of EC2 instances One t2.micro or t3.micro is free --The default EC2 instance image (AMI) is ECS compliant, so don't change it. --If you want to log in to this virtual machine later, specify the key pair for SSH. --Select the VPC (internal network in the cloud), subnet, and security group from the list (default).

Of these, the security group (firewall settings) will be changed later.

Creating a service

4-service-create

--Select "EC2" as the service accommodation (there is another Fargate) --Choose a created task --Name the service

IP address identification

You need to know the IP address to connect to the created container service. AWS EC2 assigns a DNS host name to that IP address, so you can use that.

It's hard to understand, but you can check the attributes of the container instance by selecting the cluster, selecting the EC2 instance, and looking at the details tab.

5-public-ip

Top page display:

$ curl ec2-nnnnnnnn.ap-northeast-1.compute.amazonaws.com/

View remote Markdown files:

$ curl ec2-nnnnnnnn.ap-northeast-1.compute.amazonaws.com/foo.md

Change security group

When I tested with the settings so far, the connection timed out. When I looked it up, I had to change the "security group" to open the virtual machine's port.

This is also difficult to understand, but if you select a cluster, select an EC2 instance, and go deeper and deeper, you will jump to the EC2 service, where you can change the security group.

5-edit-security-group

After the change, both the top page and the remote Markdown file were successfully displayed.


usage environment

Reference link

Sample resource

Related page of Yokohama Kobunsha

-Markdown conversion Docker -Markdown Dynamic Conversion -Markdown commentary

Written 2020/09/22

Recommended Posts

[Participation] Creating a Docker container that distributes Markdown as HTML in Apache / Pandoc --AWS container
[Part 1] Creating a Docker container that delivers Markdown in HTML with Apache / Pandoc
[Part 2] Creating a Docker container that delivers Markdown as HTML in Apache / Pandoc-remote version
Creating a lightweight Java environment that runs on Docker