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
Related
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.
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
I deploy a docker image inside Azure Container Instance. The application itself will write some log into the file. Is there some way I can log into the container to view these logs?
az container exec --resource-group <group-name> --name <container-group-name> --exec-command "<command>"
https://learn.microsoft.com/en-us/azure/container-instances/container-instances-exec
You could also create a context with docker and then use docker commands.
docker context create aci myacicontext
docker context use myacicontext
docker logs <CONTAINER_ID>
docker exec -t <CONTAINER_ID> COMMAND
https://docs.docker.com/cloud/aci-integration/#create-an-aci-context
Have found the answer.
az container logs --name your-container-name --resource-group your-resource-group-name
or
az container exec --name your-container-name --resource-group your-resource-group-name --exec-command "cat /home/yourname/xxx.log"
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.
I'm still new to the Azure Container Instance scene. I have managed to complete the container instance tutorial. However, I've noticed that the tutorial does not show the reader how to stop a running container instance. The nearest command that gaurantees the container instance is indeed stopped / terminated, is by deleting the Resource Group which created the container.
az group delete -n <ResourceGroupNameThatCreatedContainerInstance>
Is this the correct approach?
The Azure CLI updated and now its possible.
Stop
az container stop --name
--resource-group
[--subscription]
Restart
az container restart --name
--resource-group
[--subscription]
You can use az container delete
az container delete -g MyResourceGroup --name mynginx