7

Hey I wanted a design answer regarding using MySQL database in AWS ECS container . I'm not using RDS as currently doing some MVP. Is it possible to use Mysql DB as a docker container, and if it is so, then how do i make sure prod data is persisted when deployment happens of this DB container.

Please guide me for this scenario.

2 Answers 2

5

Yes, entirely possible.

Explaining it from start to finish is way too much for an SO answer. AWS has thorough documentation on ECS, and I would recommend starting there: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/Welcome.html

The section concerning data persistence is here: http://docs.aws.amazon.com/AmazonECS/latest/developerguide/using_data_volumes.html

The thing to remember with volumes and ECS - named volumes are for sharing data between containers; hosted volumes are for persisting data beyond the lifecycle of any number of containers. So you'll want to mount a volume from the underlying EC2 instance into the container where the MySQL data is stored.

Depending on which MySQL image you choose, the container data directory might differ. Any image worth it's salt is going to tell you where this directory is located in the README, because that is a very common question with databases + Docker.

Sign up to request clarification or add additional context in comments.

Comments

1

Yes it is possible. All you have to do is to find a MYSQL image such as the official one and just as instructed in the documentation of the image you will have to run:

 docker run --name my-container-name -v /my/own/datadir:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=my-secret-pw -d mysql/mysql-server:tag

The -v /my/own/datadir:/var/lib/mysql part of the command mounts the /my/own/datadir directory from the underlying host system as /var/lib/mysql inside the container, where MySQL by default will write its data files.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.