0% found this document useful (0 votes)
41 views

Docker Command

This document provides examples of using Docker commands to run containers with networking. It shows how to: - Run containers with published ports and detach them from the terminal. - List running and stopped containers. - Manage container execution with start, stop, rm commands. - Connect containers to user-defined networks and inspect the network configuration. - Run commands inside existing containers using exec. - Use network aliases to access containers on the same network.

Uploaded by

Nilesh Kadam
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
41 views

Docker Command

This document provides examples of using Docker commands to run containers with networking. It shows how to: - Run containers with published ports and detach them from the terminal. - List running and stopped containers. - Manage container execution with start, stop, rm commands. - Connect containers to user-defined networks and inspect the network configuration. - Run commands inside existing containers using exec. - Use network aliases to access containers on the same network.

Uploaded by

Nilesh Kadam
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

docker container run --publish 80:80 nginx

docker container run --publish 80:80 --detach nginx


docker container ls
docker container stop "first few digit of container id"
docker container ls
docker container ls -a
docker container run --publish 80:80 --detach --name webhost nginx
docker container ls -a
docker container logs webhost
docker container top webhost
docker container --help
docker container rm PID separated by space
docker container rm -f PID
ps aux #show all running images
docker run --name mongo -d mongo
docker ps
ps aux
docker stop CID
docker start CID
docker container run -d -p 3306:3306 --name db -e MYSQL_RANDOM_ROOT_PASSWORD=yes
mysql
docker container log db
docker container run -d --name webserver -p 8080:80 httpd
docker ps
docker container run -d --name proxy -p 80:80 nginx
docker ps
docker container ls
docker container top - process list in one container
docker container inspect - details of one container config
docker container stats - performance stats for all containers
docker container run -it -start new container interactively
docker container exec -it -run additional command in existing container
Different Linux distros in containers
-t , --tty Allocate a pseudo-TTY
-i, --interactive
docker container run -it --name proxy nginx bash
docker container run -it --name ubuntu ubuntu
apt-get update
docker container start -ai ubuntu
docker container exec -it mysql bash
ps aux
apt-get update && apt-get install -y procps
Alpine Linux
A small security-focused distribution
docker pull alpine
docker image ls
docker container run -it alpine bash
docker container run -it alpine sh
docker container run -it
docker container exec -it
docker container run -p 80:80 --name webhost -d nginx
docker container port webhost
docker container inspect --format
docker container inspect --format '{{ .NetworkSettings.IPAddsress }}' webhost
docker container ls
docker network ls
docker network inspect
docker network creatse --driver
docker network connect
docker network disconnect
docker network inspect container_id
docker network ls
docker network inspect networkID form network ls command
docker network create my_app_net
docker network create --help
docker container run -d --name new-nginx --network my_app_net nginx
docker network inspect my_app_net
docker network connect networid containerid
docker container inspect containerid
docker network disconnect networid containerid
docker container inspect containerid
docker network inspect networkid
docker container exec -it my_nginx ping new_nginx
docker container exec -it new_nginx ping my_nginx
docker network ls
docker container run --rm -it cetos:7 bash
command shift T will give you new terminals
docker container run --rm -it ubuntu:14.04 bash
apt-get update && apt-get install -y curl
docker network create dude
docker container run -d --net dude --net-alias search elasticsearch:2
docker container run -d --net dude --net-alias search elasticsearch:2
docker container ls
docker container run --rm --net dude alpine nslookup search
docker container run --rm --net dude centos curl -s search:9200

You might also like