How can i specify docker run argument in azure container creation - azure

When I run docker locally I specify the ipc argument equal to host in order to avoid insufficient shared memory problem.
docker run -it --name visdrone_cpu -p 8000:8000 --ipc host visdrone.
How can I replicate this in azure during the container creation?
az container create -g visdrone -n visdrone --image sergiocaputoo/visdrone --port 80 --ipc host unrecognized arguments: --ipc host

Based on the research, we understood that IPC (POSIX/SysV IPC) namespace provides separation of named shared memory segments, semaphores and message queues.Shared memory segments are used to accelerate inter-process communication at memory speed, rather than through pipes or through the network stack.
az container create -g visdrone -n visdrone --image sergiocaputoo/visdrone --port 80 --ipc host >unrecognized arguments: --ipc host
As per the current Azure CLI documentation,We dont have any parameter --ipc can be used in the az container create cmdlet for creating a container group.
Container group is a collection of containers running on the same host and sharing the same resources and life cycle. The concept is very similar to the pod in Kubernetes.
You can use this sample cmdlet to Create a container in a container group that runs Windows, with 2 cores and 3.5Gb of memory.
az container create -g MyResourceGroup --name mywinapp --image winappimage:latest --os-type Windows --cpu 2 --memory 3.5

Related

Azure VM/Docker – How to deploy website as Docker Container on Azure VM (Debian)

I am trying to deploy simple website as Docker Conteiner on Azure Virtual Machine port 80.
Procedure:
1 – Create VM and open port 80:
az group create --name my-vm-rg --location germanywestcentral
az vm create --resource-group my-vm-rg --name linuxVM --image Debian --admin-username <admin_user> --admin-password <admin_password> --authentication-type password --public-ip-sku Standard --size Standard_B1ms --disable-integrity-monitoring
az vm open-port --resource-group my-vm-rg --name linuxVM --port 80
2 – Connect to VM using Putty and install Docker, nano, update machine etc.
3 – Create new folder and simple index.html with <h1>Hello World</h1>
4 – Create Dockerfile
FROM nginx:1.17.1-alpine
LABEL maintainer="Name Surname <email>" description="Some random description"
COPY . /usr/share/nginx/html
5 – Build Dockerfile:
docker build -t docker-test-img .
docker image ls -a
docker run --name my-app -d -p 8080:80 docker-test-img
docker container ls -a
QUESTION: Docker container is running, but I can not access website from my local computer browser using <machine_ip_address>:80 or <machine_ip_address>:8080. I am getting „This site can’t be reached” error.
Why do I need it? I am trying to learn something new and yes, it has to be Azure VM. OS can be different.
Since you're opening port 80 in your VM, you should run your container using -p 80:80 instead.

docker inspect killed container in az cli

I created a resource group and 4 container instances in Azure. They executed JMeter command on start up. 3 containers ran for the expected amount of time (12h), one of the containers was killed after a few hours. I want to docker inspect the killed container to find out the reason it was killed (I suspect OOM).
This is what I have done:
I logged in to Azure using az cli locally under PowerShell 7
I ran az container --help and can see available commands are:
I can't see a way to run docker inspect on a stopped container...
When I ran:
az container exec --exec-command "docker inspect" --name c3 --resource-group my_resource_group
I understandably get the BadRequestError: Container Group c3 is stopped
Can I docker inspect a stopped container in az cli?

Running Gitlab Runner in Azure Container Instances (ACI)

I would like to run Gitlab-Runner in Azure Container Instances (ACI).
For this I have the docker container gitlab/gitlab-runner running in the Azure ACI.
With the following command I register this runner for my Gitlab server.
gitlab-runner register \
--non-interactive \
--run-untagged=true \
--locked=false \
--executor "docker" \
--docker-image docker:latest \
--url "https://gitlab.com/" \
--registration-token "MyTokenYYYYYYYY" \
--description "my-own-runner" \
--tag-list "frontend, runner" \
--docker-volumes /var/run/docker.sock:/var/run/docker.sock
The new runner is also recognized under gitlab. However, when I run a job, I get the following error.
Preparing the "docker" executor
ERROR: Failed to remove network for build
ERROR: Preparation failed: Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? (docker.go:960:0s)
If I run the Runner with the identical configuration locally on my notebook everything works. How do I get it to work in the Azure ACI?
How can I mount the docker sock in the Azure ACI when registering it?
Many thanks in advance for your help.
You're not going to be able to run another docker container inside the container you created in Azure ACI. In order to achieve "docker-in-docker" (dind), the daemon instance (your ACI container in this case) needs to be running in privileged mode which would allow escalated access to the host machine that you are sharing with other ACI users. You can read about this more on Docker hub where it says:
Note: --privileged is required for Docker-in-Docker to function
properly, but it should be used with care as it provides full access
to the host environment, as explained in the relevant section of the
Docker documentation.
The common solution for this is to use an auto-scale group of 0 or more VMs to provide compute resources to your gitlab runners and the containers they spawn.
Gitlab docs - docker-machine autoscaler
blog post re: doing this on Azure https://www.n0r1sk.com/post/on-premise-gitlab-with-autoscale-docker-machine-microsoft-azure-runners/

Connecting to a jenkins container running on azure

I'm currently running jenkins from a container on my azure container instances, but I'm having difficulty with connecting. I specified port 80 when I run the CLI command:
az container create -g MyResourceGroup --name MyName --image MyImage --ports 80
Is there something I missed or another way I could configure it from the portal so that I can connect and setup jenkins? Any help would be appreciated.
The possible reason is that your container instance is not accessible outside because you do not expose it to the Internet. If you want to expose it to the Internet, the command should be like this:
az container create -g MyResourceGroup --name MyName --image MyImage --ports 80 --ip-address Public
For more details, see parameter --ip-address in az container create.
Or you can connect into the container instance through the CLI command az container exec -g MyResourceGroup --name mynginx --container-name nginx --exec-command "/bin/bash" or exec the command in the portal.
In addition, it seems you run Jenkins in the container instance. I would not recommend you do this. Because the Container Instance is a light-weight service, if you run a server in it, then it won't be actually what it should be anymore. The VM is an appropriate host for the Jenkins server. See Jenkins in VM.
Did you specify the DNS name with the parameter --dns-name-label

Running docker commands in an Azure container

I've been struggling far longer than I should have on this and I'm sure I must be doing something the hard way.
Basically all I want to do is run a docker image in azure (the eos-dev blockchain image). I've gone through and created the container registry, enabled admin control and created the container using:
az container create --resource-group docker --name eosnode --image xxx.azurecr.io/eos-dev --cpu 1 --memory 14 --ip-address public --ports 80 7777 5555 --registry-password "zzz"
Now if this was a local docker instance id simply be able to run:
docker network create testnetwork
And I would get this back:
77af2f92d66895bbf71490b33d775a116d6d8d7be0cbd0a2b3d18ce7336cf611
Now, I'm attempting to do it on the remote azure container like this:
az container exec -g docker --name eosnode --container-name eosnode --exec-command "docker network create testnetwork"
But it returns nothing and I have no idea if it even did anything. What am I missing here?
As you say, you just want to run a docker image in Azure. And I see you create the container instance with the command:
az container create --resource-group docker --name eosnode --image xxx.azurecr.io/eos-dev --cpu 1 --memory 14 --ip-address public --ports 80 7777 5555 --registry-password "zzz"
For this step, the container instance is created in Azure. And you can get the instance information through the command az container show or get logs of the instance with the command az container log.
Also, you can execute the command inside the container instance using the command like this:
az container exec -g resrouceGroup -n instanceName "bash command"
But if you want to run the command docker network create testnetwork inside the container instance, you should install the docker inside the image which you create the container instance from.
docker network create
creates a docker network on the machine/host, the hash code returned is the id of the network. All 'docker' commands suppose to run on the host instead of in container.
Docker network is not necessary to run container in Azure Container instance.
If a container image requires a command to start, usually the command can be found in its document/example with:
docker run <image> <command>
The equivalent way to run the container in azure container instance is:
az container create -g <resourceGroup> -n <name> --image <image> --command-line <command> --restart-policy <Always|OnFailure|Never>
--command-line: specify the command to run in the container
--restart-policy: Define the behavior when the command exit.

Resources