Docker

docker container run hello-world

docker image pull alpine

docker image ls

docker container run alpine ls -l

docker container run alpine echo “hello from alpine”

docker container run -it alpine /bin/sh

docker container run –help

docker container ls -a

docker container start <container ID>

docker container exec <container ID> ls

  • Images – The file system and configuration of our application which are used to create containers. To find out more about a Docker image, run docker image inspect alpine. In the demo above, you used the docker image pull command to download the alpine image. When you executed the command docker container run hello-world, it also did a docker image pull behind the scenes to download the hello-world image.
  • Containers – Running instances of Docker images — containers run the actual applications. A container includes an application and all of its dependencies. It shares the kernel with other containers, and runs as an isolated process in user space on the host OS. You created a container using docker run which you did using the alpine image that you downloaded. A list of running containers can be seen using the docker container ls command.
  • Docker daemon – The background service running on the host that manages building, running and distributing Docker containers.
  • Docker client – The command line tool that allows the user to interact with the Docker daemon.
  • Docker Store – Store is, among other things, a registry of Docker images. You can think of the registry as a directory of all available Docker images. You’ll be using this later in this tutorial.

 

docker container run –detach –name mydb -e MYSQL_ROOT_PASSWORD=my-secret-pw mysql:latest

docker container top mydb

docker exec -it mydb mysql –user=root –password=$MYSQL_ROOT_PASSWORD –version

docker exec -it mydb sh

 

docker image build –tag <dockerID>/<appName>:<version> .
Note:  (.) at the end of the above command is to represent the current directory as the build context

docker container run –detach –publish 80:80 –name <appName> <dockerID>/<appName>:<version>
Note: –publish maps the port inside the conatiner to the host port (–publish host_port:container_port)

docker container rm –force <appName>

 

bind mount
docker container run –detach –publish 80:80 –name <appName> –mount type=bind,source=”$(pwd)”,target=/usr/share/nginx/html <dockerID>/<appName>:<version>

 

docker image ls -f reference=”<dockerID>/*”

docker login

docker image push <dockerID>/<appName>:<version>