How to debug your docker container part 2
So far we have learned how to run the container and how to start debugging it. If you haven't checked the older articles then I would suggest do check the older articles.
Today I am going to run the sql server server image which I have downloaded. If you don't have sql server image then you can download it with below commands.
docker pull mcr.microsoft.com/mssql/server:2019-latest
docker pull mcr.microsoft.com/mssql/server:2019-latest
2019-latest: Pulling from mssql/server
Note: In above command I wanted to mention that here I have given microsoft's address to download the image. If you don't provide the address then it will use docker hub to pull the image by default.
Once its downloaded ,let's run the image in container.
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=test" -p 1433:1433 --name sqltest1 -h sqltest1 -d mcr.microsoft.com/mssql/server:2019-latest
Let's check if container is running:
docker ps
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
No container is running! why I did everything correct. Let's check all containers.
docker ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
a03d10d598e5 mcr.microsoft.com/mssql/server:2019-latest "/opt/mssql/bin/perm…" 5 minutes ago Exited (1) 5 minutes ago sqltest1
Lets check the logs:
docker container logs a03d10d598e5
You will see lots of logs. Just scroll down to very bottom and that's your error.
2021-09-15 08:07:21.10 spid25s ERROR:Unable to set system administrator password: Password validation failed. The password does not meet SQL server password policy requirements because it is too short.
So now we know that our password was culprit. Let's change the password and run the command again.
I'll remove the container sqltest1 because it will give you conflict issues on container name. Either you can remove or change the container name in the command.
docker container rm a03d10d598e5
docker run -e "ACCEPT_EULA=Y" -e "SA_PASSWORD=Test@123" -p 1433:1433 --name sqltest1 -h sqltest1 -d mcr.microsoft.com/mssql/server:2019-latest
Now run the docker ps to check running container. You should be able to see it.
Great! we have now learnt some basics of Docker.
Note: If you think this helped you and you want to learn more stuff on devops, then I would recommend joining the Kodecloud devops course and go for the complete certification path by clicking this link
No comments:
Post a Comment