Develop Intelligence - Docker Docker Commands: Agenda: Getting Started With Docker
Develop Intelligence - Docker Docker Commands: Agenda: Getting Started With Docker
Note:
1. You can develop both Docker Linux containers and Docker Windows containers with Docker for Windows.
2. Virtualization must be enabled. You can verify that virtualization is enabled by checking the Performance tab
on the Task Manager.
3. The Docker for Windows installer automatically enables Hyper-V for you.
4. Containers and images created with Docker for Windows are shared between all user accounts on machines
where it is installed. This is because all Windows accounts use the same VM to build and run containers.
5. We can switch between Windows and Linux containers.
First, make sure the Docker installation is working correctly by running docker version. The output should tell you
the basic details about your Docker environment:
Make sure the Docker installation is working correctly by running docker version. The output should tell you the
basic details about your Docker environment.
Note: The OS/Arch field tells you the operating system you're using. Docker is cross-platform, so you can manage
Windows Docker servers from a Linux client and vice-versa, using the same docker commands.
In case Docker Engine is not starting on Windows 10, Run the following commands
1. https://wslstorestorage.blob.core.windows.net/wslblob/wsl_update_x64.msi
2. wsl --set-default-version 2
Docker Commands
Listing all images from local registry:
docker version
docker pull hello-world
docker pull nginx
docker pull alpine
docker pull ubuntu
docker image history nginx
docker inspect nginx
docker images
docker image ls
docker images --no-trunc (List full lengh image IDs)
docker images --filter=reference=alpine
Develop Intelligence – Docker Docker Commands
Some things to note:
1. IMAGE ID is the first 12 characters of the true identifier for an image. You can create many tags of a given
image, but their IDs will all be the same (as above).
2. VIRTUAL SIZE is virtual because it's adding up the sizes of all the distinct underlying layers. This means that the
sum of all the values in that column is probably much larger than the disk space used by all of those images.
3. The value in the REPOSITORY column comes from the -t flag of the docker build command, or from docker tag-
ing an existing image. You're free to tag images using a nomenclature that makes sense to you, but know that
docker will use the tag as the registry location in a docker push or docker pull.
4. The full form of a tag is [REGISTRYHOST/][USERNAME/]NAME[:TAG]. For ubuntu above, REGISTRYHOST is
inferred to be registry.hub.docker.com. So if you plan on storing your image called my-application in a registry
at docker.example.com, you should tag that image docker.example.com/my-application.
5. The TAG column is just the [:TAG] part of the full tag. This is unfortunate terminology.
6. The latest tag is not magical, it's simply the default tag when you don't specify a tag.
7. You can have untagged images only identifiable by their IMAGE IDs. These will get the <none> TAG and
REPOSITORY. It's easy to forget about them.
Exec Lab
• Start a new container from the nginx image on Docker Hub
• Using exec, get into the container and have a look around
• Visit the web site and make sure you see the default home page.
• Now go change the home page index.html file located in /usr/share/nginx/html.
• Add file /usr/share/nginx/html/hello.html (use echo)
• Verify that your changes show in the web site.
Solution:
• docker run -p 8080:80 -d --rm nginx
• docker ps
• docker exec -it <container name> /bin/sh
• # cd /usr/share/nginx/html
• # echo "hello" > "hello.html"
• # exit
• curl http://localhost:8080/hello.html
• docker commit <container id> myngnix
Develop Intelligence – Docker Docker Commands
• docker run -p 8081:80 mynginx
• curl http://localhost:8081/hello.html
Solution:
MSSQL Server
docker run -e "ACCEPT_EULA=Y" -e "MSSQL_SA_PASSWORD=Password_*123" --name "sql-demo" -e
"MSSQL_PID=Developer" -d -p 1412:1433 -v db-data-sqlsrv:/var/opt/mssql mcr.microsoft.com/mssql/server:2019-
latest
MySQL Server
docker run --name some-mysql -e MYSQL_ROOT_PASSWORD=Password_*123 -d -p 3306:3306 -v db-data-
mysql:/var/lib/mysql mysql