I tried do run a docker in pipeline ,first i tried to use documentation : https://learn.microsoft.com/en-us/azure/devops/pipelines/tasks/reference/docker-v2?view=azure-pipelines&viewFallbackFrom=azure-devops&tabs=yaml#troubleshooting but still got errors
Its looks like my pipeline properly download a docker file but when i try to exec any command in docker file i got errors
steps:
- checkout: self
clean: true
fetchDepth: full
- task: Docker@2
displayName: Login to ACR
inputs:
containerRegistry: 'Docker'
command: 'login'
- script: |
docker run -d docker.io/Docker/Sample-docker-image
displayName: 'Run Docker'
- task: Docker@2
inputs:
containerRegistry: 'Docker'
command: 'start'
container: 'Docker/Sample-docker-image'
when i run this i got
Error response from daemon: No such container: ***/Docker/Sample-docker-image
Error: failed to start containers: ***/Docker/Sample-docker-image
##[error]Error response from daemon: No such container: ***/Docker/Sample-docker-image
##[error]Error: failed to start containers: ***/Docker/Sample-docker-image
##[error]The process '/usr/bin/docker' failed with exit code 1
How to handle and properly use a docker ? Im doing something wrong in this yml ?
Edit: i added
container_id=$(docker run -d Docker/Sample-docker-image)
echo "Container ID: $container_id"
echo "##vso[task.setvariable variable=container_id]$container_id"
container_id=$(echo $container_id)
while [[ "$(docker inspect -f '{{.State.Status}}' $container_id)" != "running" ]]; do
docker inspect $container_id
docker logs $container_id
sleep 10
docker ps -a
done
and it shows docker starts as exited status. i tried locally and every image works as expected
Thank you for answers. I made mistake only thing which i missed is a letter -t
docker run -t -d --name my-container
This solved a issue, container is running and im able to run docker exec