Note: To prevent to type sudo all the time. You have to add your linux user to docker group.
Lists version of Docker
$ docker version
Lists detailed information of Docker environment.
$ docker info
Lists all Docker commands. Docker commands usually work like this "docker command subcommand".
$ docker --help
This command download the nginx image and run container with given port information. First port is hosts ports you can think it's your local machine port. Second port is container's port. Ex. if the port configuration was like 8888:80 you have to navigate "localhost:8888" from your browser.
$ docker container run --publish 80:80 nginx
--detach or -d command lets container to run in background.
$ docker container run --publish 80:80 --detach nginx
You can name your container by --name command.
$ docker container run --publish 80:80 --detach --name webhost nginx
Assign environment variables by --env or -e parameter.
$ docker container run --publish 3306:3306 --detach --name db --env MYSQL_RANDOM_ROOT_PASSWORD=yes mysql
Lists running containers.
$ docker container ls
Lists all containers including stopped ones.
$ docker container ls -a
Lists container logs by container name.
$ docker container logs webhost
List container processes by container name.
$ docker container top webhost
List container performance, memory etc. stats by container name or blank*. Blank name shows every running container stats.
$ docker container stats webhost*
Inspect container processes by container name.
$ docker container top webhost
Stop container by container id.
$ docker container stop 3 0 b
Delete containers by ids. You can use first letters of container ids if they are unique. Running containers will not delete by this command.
$ docker container rm f15 cf4 b8f d7b f9f
Deletes containers with force. Running containers will be deleted by this command.
$ docker container rm -f f15