How to push the application to aws and run with docker

Hi Experts,

   I got a server which runs applications with docker and aws, running from console(putty).  The command to run is as follows:-

docker run --name ts_pull ${ts_environment[@]}  -d  --restart always 1234656458.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-ts:1.0.2 start pull

Open in new window


I can understand 1234656458.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-ts:1.0.2 is from aws.  Can any tell me how this container application is pushed to aws?

From the documentation I found Dockerfile is available, from which the docker image is built.  I don't understand how to push this to aws and run with the docker.

Please throw some light over it.

with many thanks,

Bharath AK
LVL 1
Bharath A.KAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Sounds like you're using a stock AWS instance, rather than custom.

If you build a custom AWS instance, then you bake in all your Docker code into the instance.

If you use a stock AWS instance, then you root ssh into your AWS instance, using the ssh key AWS returns when instance spins up.

Then always add another ssh key so you always have a known key to access all your instances, so you can throw away the temp key returned from AWS at instance spin up time.

Then pull files you require onto your AWS instance, normally via curl or wget.

Then build your Docker container + spin it up.
0
Bharath A.KAuthor Commented:
Hi David,

      Thanks for your reply.   Aws instance is ubuntu machine.  I connect to it through putty.  I don't understand  what stock aws instance means.  everything is in the ubuntu machine.   it has postgres database, elastic search, python, wagtail, django, dockers etc.   Harvest-ts is a python application, which is run as cron.  I don't understand how this is pushed into aws as docker container.  Could you please elaborate more or provide me links so that I can learn and understand what you mean.  

With Many thanks,

Bharath AK
0
David FavorLinux/LXD/WordPress/Hosting SavantCommented:
Two types of instances.

Custom - you generated it from scratch + you'd know if you did this.

Stock - you use an already existing AWS instance.

If you connect through Putty then you're likely running a root shell.

So you'll just follow one of the many guides to running a Docker container on Ubuntu.

Just think of your AWS instance as a dedicated server running Ubuntu... which it is, although very slow as AWS uses have VMs.

Just go to the Docker site + or where ever you acquired the Docker container config you're using for your application.

https://hub.docker.com/ is a good starting point.
0
Challenges in Government Cyber Security

Has cyber security been a challenge in your government organization? Are you looking to improve your government's network security? Learn more about how to improve your government organization's security by viewing our on-demand webinar!

Bharath A.KAuthor Commented:
Hi David,

      Thanks for your reply.

      a) There is a DockerFile in repository to build the image for harvest-ts.  My understanding is  After building the docker image it is pushed to aws?  and docker run pulls the image from aws and runs the container.  This is what i have understood. is this right?  please correct me if i am wrong.  my next question is how to push this image to aws.

    b)  I have another question, harvest -ts is a cron it stops and continues after some time.  if this as docker container, will it stop and start at intervals.

     Please correct me wherever I am wrong.  sorry, I feel I am troubling with more questions I don't have clarity

Thank you so much.

Kind Regards,
Bharath AK
0
Prabhin MPEngineer-TechOPSCommented:
Hi Bharath,
docker run --name ts_pull ${ts_environment[@]}  -d  --restart always 1234656458.dkr.ecr.ap-southeast-2.amazonaws.com/harvest-ts:1.0.2 start pull

From the above command, the docker image is pulled from AWS ECR ( Ec2 Container registry) not docker hub.

1234656458.dkr.ecr.ap-southeast-2.amazonaws.com is the AWS ECR account
harvest-ts  is the image name
1.0.2 is the tag assigned to it. We can have multiple tags for the same image.


Now coming to your question "How docker image is pushed?"
      As you are using custom docker image, there will be dockerfile which contain all the configuration required for it. Once the image created using the following command
      docker built -t imagename:tagname .

After executing the above command new Docker image gets generated. Now the next step is to push docker image to Docker registry.  I hope you are using AWS ECR.
So first you need to log in your registry account using the following command,

Make sure that you have installed AWS CLI.


aws ecr get-login --no-include-email --region us-west-2

Where us-west-2 is the region where you created the registry.

Once you logged, tag the newly created image to push AWS registry,

using the following command,
docker tag imagename:tag 1234656458.dkr.ecr.ap-southeast-2.amazonaws.com/imagename:tag

Now you can push the image directly to AWS ECR using the following command,

docker push 1234656458.dkr.ecr.ap-southeast-2.amazonaws.com/imagename:tag


I Hope the above information helps you. Let me if you have any clarifications,
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Bharath A.KAuthor Commented:
Hi Prabin,

    I have one more doubt, How the cron job harvest:ts runs, cron jobs runs at an interval how this Harvest-ts cron works.  Could you please through some light over it.  will it start and stop frequently

With Many thanks,
Bharath AK
0
Prabhin MPEngineer-TechOPSCommented:
Hi Bharath,
Looks like there might be a problem with your docker file cron configuration,

Please refer the following link to configure cron correctly,
https://stackoverflow.com/questions/37458287/how-to-run-a-cron-job-inside-a-docker-container

and change your docker file accordingly.
I Hope this will help you.
0
Bharath A.KAuthor Commented:
Hi All,

     Thank you so much for providing me clarity on this.

With Kind Regards,

Bharath AK
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
python3

From novice to tech pro — start learning today.