Build Data Analysis Enviornment on Docker on AWS
Install Docker on EC2
|
|
docker images
fails by permission denied error. So, we make a group name docker
and add ubuntu
user.
|
|
Then docker images
works.
Option 1: Upload docker image to AWS
There are several cases to do upload docker image to AWS.
- User docker registry
- Use Docker file (light, but possibility to change build context)
- Make docker image to tar file and send it.
Make docker image to tar file.
If you cannot access internet on your host environment (EC2 in this case), you need to send docker image by tar file.
|
|
Make a tiny docker image on a temporary directory (e.g. ~/repo/dhub/tmp_image
) on host (M1 Mac)
|
|
Dockerfile
|
|
Build an image
|
|
Save an image as tar file
|
|
Then you will see a tar file.
Upload docker image (tar file) to EC2 by SFTP
|
|
For example:
|
|
Load docker image from tar file
On EC2,
|
|
|
|
Option 2: Upload Dockerfile
|
|
After uploading Dockerfile to EC2, build docker image.
|
|
This fails because the disk space of T2 Micro is limited(<8GB) that is less than the docker image.
- docker image consumptions on Linux:
/var/lib/docker
. (When mac case,~/Library/Containers/com.docker.docker/Data
). - Docker daemon’s configuration file:
/etc/docker/daemon.json
On EC2;
|
|
Expand the disk size of EC2
Change EBS (Elastic Block Store). On EBS, Action > Modify Volumes, and change the size into 20GB.
If the root (/
) has not been expanded, check the volume size by lsblk
.
|
|
If the size of root partition is not changed,
|
|
If file system is ext4
,
|
|
Build iamge and run jupyter on AWS
After expanding the disk space, you will successfully build an image. On EC2,
|
|
After the installation finishes, you can run a container with data analysis environment (Jupyte lab in this case).
|
|
You can access <public DNS host name>:8888
from web browser.
Change Security group
If you cannot access to Jupyter Lab on EC2, you may need to create a security group and change the configuration.
On EC2 dashboard, Network & Security
> Security Group
, Create Security Group
.
Inbound and Outbound Rule:
- Type: All Trafic
- Source: 0.0.0.0/0
Then assign the security group to EC2 instance. In my case, this solves the access error on Jupyter Lab on a browser.
This is an experimental project, but you need to limit IP address and/or token access for the Jupyter Lab.
Control container and volume access authorization
On EC2 instance, we can create user freely (more than local laptop environment)
|
|