How does Docker and AWS ECS Service interact? - docker

i'm new to amazon web services, and im involved in project where we dicided to user serverless architecture which consist of lambda(nodejs), dynamo DB, cognito etc, as a DevOps engineer, im trying to figure out how to to do CD/CD for the project.
I've read multiple articles, they mentioning fargate and other services which i understand, but when it comes to docker and ECS im bit confused, *
i dont know if we push the image to ECS and write the dockerfile so that my lambda functions can run, or we just push the image to ECS so that the cluster of lambda functions can run?
please anyone with a clear explanantion please assist.
Thank you

i dont know if we push the image to ECS and write the dockerfile so
that my lambda functions can run, or we just push the image to ECS so
that the cluster of lambda functions can run?
You push Docker images to AWS Elastic Container Registry (ECR). ECS can then pull those images to deploy docker containers in either EC2 or Fargate.
ECS, ECR and Docker are totally unrelated to AWS Lambda. You don't run docker containers in AWS Lambda.

Implemented similar using Jenkins.. We have create docker image using jenkins as part of CI CD pipeline.. then we store those docker images in ECR. In ECS we create task definition and container instance, then container instance will refer to the ECR images which we created as part of CICD.
Dokcerfile was part of docker image.

Related

Using Artifactory instead of ECR

We've just brought Artifactory into our organization. We have a lot of Fargate stacks that are pulling the Docker images from ECR. We now want to pivot and store our Docker images in Artifactory and tell Fargate to pull the images from Artifactory.
Does anyone know how to do this?
Thanks
An Artifactory repository for Docker images is a Docker registry in every way, and one that you can access transparently with the Docker client (see documentation)
In Artifactory, start by creating a local Docker repository, then follow the "Set Me Up" instructions for that repository to upload/deploy your docker images to it.
The "Set Me Up" dialog for the Docker repository also provides the steps to have your docker clients consume/download the images from your Docker repository/registry. You would just have to replace the references of ECR with the one for your Artifactory docker repository/registry in your docker client commands.
This documentation page provides step-by-step information on how to use Artifactory as a Docker registry.
Artifactory also provides the capabilities of Remote Docker repositories, which provides proxying/caching of external registries, and Virtual Docker repositories for the aggregation of both local and remote repositories into one single entry point.

How to set AWS region using docker compose up with ECS context

I'm using the new docker compose ECS integration to create an ecs context for deploying as described here and here. I selected during docker context create ecs my-context for it to use an existing AWS profile which has us-west-2 configured as its default region. However, docker compose up always results in it deploying to us-east-1. I tried exporting DEFAULT_AWS_REGION but that didn't work either. Is there a way to set the region in the context? It looks like the older docker ecs setup command asked for the region but that cmd is now deprecated.
I was able to fix this via the AWS CLI directly.
aws configure set default.region eu-central-1
Source: https://awscli.amazonaws.com/v2/documentation/api/latest/reference/configure/set.html

How to write a file to the host in advance and then start the Docker container?

My task is to deploy a third-party OSRM service on Amazon ECS Fargate.
For OSRM docker at startup, you need to transfer a file containing geodata.
The problem is that Amazon ECS Fargate does not provide access to the host file system and does not provide the ability to attach files and folders during container deployments.
Therefore, I would like to create an intermediate image that, when building, saved the file with geodata, and when starting the container, it would use it when defining volumes.
Thanks!
As I understand it, Amazon ECS is a plain container orchestrator and does not implement docker swarm, so things like docker configs are off the cards.
However, you should be able to do something like this :-
ID=$(docker create --name my-osrm osrm-base-image)
docker cp ./file.ext $ID:/path/in/container
docker start $ID
The solution turned out to be quite simple.
For this Dockerfile, I created an image on my local machine and hosted it on DockerHub:
FROM osrm/osrm-backend:latest
COPY data /data
ENTRYPOINT ["osrm-routed","--algorithm","mld","/data/andorra-latest.osm.pbf"]
After that, without any settings and volumes, I launched this image in AWS ECS

Google Cloud Composer - Deploying Docker Image

Definitely missing something, and could use some quick assistance!
Simply, how do you deploy a Docker image to an Airflow DAG for running jobs? Does anyone have a simple example of deploying a Google container and running it via Airflow/Composer?
You can use the Docker Operator, included in the core Airflow repository.
If pulling an image from a private registry, you'll need to set a connection config with the relevant credentials and pass it to the docker_conn_id param.

Redeploy all docker services by image on my swarm

my workflow is:
push code with git
Build docker image on my CI server (drone.io)
Push image to my private registry
Here I need to update all services in all stacks with this new image version from registry
Have anyone idea how to do it in a proper way?
I saw an official tutorial for rolling updates in docker docs.
docker service update --image <image>:<tag> service_name
But there is a problem that I don't know service and stack names.

Resources