Hello Guys, Ever thought of running a GUI application in a docker container on the top of AWS EC2 instance . I am sure you guys have tried it earlier in Vms in your virtual box or VM ware or any else software you have.
But Guys, many a times we don’t have so much of compute resources so here cloud plays a vital role which helps us to perform work easily without facing any lagging issues while creating a application or when you are performing some task or your office work it can be anything… So, to avoid that and save your time cloud is there you can launch your applications over there without facing any latency or any ram issues which can cause lagging issues in your system .
So, let’s get started with the hand’s on part…. But before starting some prerequisites which you need before doing this task are as follows :-
- AWS EC2 Instance
For installing Docker on AWS EC2 instance you can follow the below document 👇👇👇
Docker basics for Amazon ECS
Docker is a technology that provides the tools for you to build, run, test, and deploy distributed applications that…
To check the version of docker available on your instance you can use the below command 👇👇👇
Setting up my Sql
docker run --name local-mysql -e MYSQL_ROOT_PASSWORD=12345 -d mysql:5.7
Let’s chop down this command so that we know what is going on here. The first segment is
docker run which exactly does what it says it does: running a docker container. Next,
--name local-mysql sets the container name that we are creating. You can change the name with whatever you want.
-e sets environment variable for running the container and here we set
MYSQL_ROOT_PASSWORD which is mandatory to run this image.
-d tells docker to run the container in background. Lastly,
mysql:5.7 designate that we want to run version 5.7 of mysql image. We can also use
mysql that will give us the latest version of the image.
To check whether the container is launched or not use the below command ✨✨✨
Now let’s add a new database for our Wordpress by executing mysql in the container.
docker exec -it local-mysql mysql -u root -p
The above command is straightforward, ie. execute
mysql -u root -p inside the
local-mysql container. The
-it flag tells docker to be interactive in executing the command and allocate pseudo-tty. After that, we will be inside mysql prompt and we can run mysql to create a new database.
mysql> create database wordpress;
Setting up Wordpress
docker run --name local-wordpress -p 8080:80 -d wordpress
It is pretty much the same with when we run mysql, the difference is here we have
-p 8080:80 which tells docker to have port mapping. Our machine’s
8080 port will be forwarded to the container’s
80 port. Now, we can access our wordpress by accessing http://Public ipv4 of your instance:8080/ on the browser and complete the setup wizard there.