How to use docker compose v2 in pipelines - docker

How can I target the v2 of docker compose using a private container registry from service connections in pipelines ?
I cannot find any way to do so in the DockerComposeV0 task.
And using bash directly is not practical as I need to access my container registry from service connections.

Related

How to start docker registry as a local process, not run in container?

The official doc provides a way to run docker registry on containers, but given the situation that it is not allowed to run the registry in the container, how to start docker-registry without docker?
There are multiple options. You can use one of the following repository manager to easily setup a docker private registry and use that.
Sonatype nexus
GitLab container registry

Openshift privileged container access services from openshift namespace

I'm trying to run my custom Jenkins on Openshift. I'm trying to run dockerized pipelines using privileged containers and scc to be able to run docker using my Jenkins. So far, I managed to run the job and it is creating a new Docker container successfully. But, since my new docker is created by Jenkins it doesn't have access to Nexus service on my project. How can I fix this? I was thinking the solution should be for the Jenkins to run docker in the same namespace as my Jenkins.
I'm assuming that you want to run your container in Kubernetes.
On your Deployment I would advise using either a ConfigMap or if you want to keep in encrypted in the cluster you can use a Secret to store your Nexus credentials.
Then you can mount your ConfigMap or Secret under ~/.ivy2/.credentials for example.

Deploying multiple docker containers to AWS ECS

I have created a Docker containers using docker-compose. In my local environment, i am able to bring up my application without any issues.
Now i wanted to deploy all my docker containers to the AWS EC2 (ECS). After going over the ECS documentation, i found out that we can make use of the same docker-compose to deploy in ECS using ECS-CLI. But ECS-CLI is not available for windows instances as of now. So now i am not sure how to use my docker-compose to build all my images using a single command and deploy it to the ECS from an windows instance.
It seems like i have to deploy my docker containers one by one to ECS as like below steps,
From the ECS Control Panel, create a Docker Image Repository.
Connect your local Docker client with your Docker credentials in ECS:
Copy and paste the Docker login command from the previous step. This will log you in for 24 hours
Tag your image locally ready to push to your ECS repository – use the repo URI from the first step
Push the image to your ECS repoository\
create tasks with the web UI, or manually as a JSON file
create a cluster, using the web UI.
Run your task specifying the EC2 cluster to run on
Is there any other way of running the docker containers in ECS ?
Docker-Compose is wrong at this place, when you're using ECS.
You can configure multiple containers within a task definition, as seen here in the CloudFormation docs:
ContainerDefinitions is a property of the AWS::ECS::TaskDefinition resource that describes the configuration of an Amazon EC2 Container Service (Amazon ECS) container
Type: "AWS::ECS::TaskDefinition"
Properties:
Volumes:
- Volume Definition
Family: String
NetworkMode: String
PlacementConstraints:
- TaskDefinitionPlacementConstraint
TaskRoleArn: String
ContainerDefinitions:
- Container Definition
Just list multiple containers there and all will be launched together on the same machine.
I got the same situation as you. One way to resolve this was using the Terraform to deploy our containers as a Task Definitions on AWS ECS.
So, we using the docker-compose.yml to run locally and the terraform is a kind of mirror of our docker-compose on AWS.
Also another option is Kubernetes that you can translate from docker-compose to Kubernetes resources.

Docker API, remote API, Client API

I would like to know when to use and the difference between Docker API, Docker remote API, Client API and Compose API. TIA.
There is only Docker Engine API, which allows you to manage Docker calling it.
Docker API = Docker Engine API
Docker remote API = I think this means to configure Docker CLI to connect to a remote API to manage container on other hosts.
Client API = Docker CLI. A CLI to use Docker Engine API.
Compose API = This doesn't exist, Compose is only a tool to use Docker Engine API.
For further information, check Docker Engine API docs: https://docs.docker.com/engine/api/
Basically all the categories that you are referring to are Docker Engine APIs
As per the Docker Docs:
The Engine API is the API served by Docker Engine. It allows you to
control every aspect of Docker from within your own applications,
build tools to manage and monitor applications running on Docker, and
even use it to build apps on Docker itself.
It is the API the Docker client uses to communicate with the Engine,
so everything the Docker client can do can be done with the API. For
example:
Running and managing containers Managing Swarm nodes and services
Reading logs and metrics Creating and managing Swarms Pulling and
managing images Managing networks and volumes
These APIs are used to control Docker on the remote servers.
Docker Compose is a tool for defining and running multi-container Docker applications.
These APIs are used to control Docker on the remote servers.
Docker Compose is a tool for defining and running multi-container Docker applications.
Thanks, I was trying to understand the difference between the Docker APIs while working on this Scalable Docker Deployment in the Bluemix platform.

Call Docker API without docker daemon

I was wondering is there a way to make a call to Docker API without docker daemon.
I went through their docs and a little bit of source code behind Docker CLI and couldn't find an answer.
I want to make a HTTP/HTTPS call to Docker API directly! I don't want to install docker CLI. Is this somehow possible and can you give an example?
EDIT:
I want to make Docker Registry API call without having to install docker to test credentials, which I would later use for docker login command.
I think your question is a little confused. You can't make a call to the Docker API without the Docker daemon because the API is the daemon (or at least, the daemon exposes the API).
You can of course make requests to (control) the API / daemon without the Docker client though. Simply fire your requests at the socket (unix:///var/run/docker.sock) directly. Or if you want to expose it as HTTP(S recommended) then you can do this by altering the daemon startup options and instead send request over HTTP(S) to that address.
docker CLI <==[ Docker Engine API ]==> dockerd
The docker CLI communicates with a docker daemon using the Docker Engine API. The latest version is v1.41
The CLI and daemon don't need to be on the same machine. By setting the docker context, you can direct the docker CLI to communicate with a remote docker daemon, hence without installing Docker locally. Similarly, if you issue Docker Engine API calls using curl or any other SDK, you may use unix:///var/run/docker.sock for the local daemon (if installed), or the URL of the remote daemon.
dockerd <==[ Docker Registry API ]==> Docker Registry
The docker daemon communicates with a docker registry using the Docker Registry API. The latest version is v2. A docker pull alpine tells the daemon at the current context to issue a Docker Registry API call to the https://registry-1.docker.io/v2 endpoint at DockerHub, while docker pull registry.gitlab.com/username/image:tag tells the daemon to issue a Docker Registry API call to the https://registry.gitlab.com/v2 endpoint at your private GitLab container registry.

Resources