Docker Commands
Docker pull <image name> = to pull image (ubuntu)
Docker run -it -d <image name> = to make container (it- interactive terminal) (d – detached
mode/background)
Docker ps = to check container list
Docker login = to login with the docker hub
Docker run -it -d –name=<name for container> <image name>= for identification of
container/specifying container name (it creates new container Id)
Docker exec -it <container id> <container command> = to modify container(ubuntu - /bin/bash
alpine – ping 8000)
apt -get update = to update the changes If any
exit = to exit container
docker commit <container id> <username/new image name> = to create image name
Docker images = to check images list
Docker login = to login with the docker hub
Docker push <image name> = to push image to docker hub
Docker rmi <image name> = to delete image
Docker logout = to logout from docker hub
Docker File
(To create image with the help of text file without docker commands)
File content:- (for html website)
FROM nginx:alpine
COPY . /usr/share/nginx/html
docker build -t <imgname> . = for creating new image {. For accessing all files}
docker run -it -p <8000:80> <imgname> = for running image
Docker Network
Docker network ls = to check the network(by default bridge)
Docker network –help = to see docker network commands
Docker network prune = to remove all unused network
Docker network rm = to remove particular network
Docker run -it network—< networkname > -p 8000:8000 <imagename> = to run network
Docker exec -it <containerid> sh
Hostname =for container host
Hostname -i =for ipaddress
Docker network create <network name>
Docker run -it network=(sage)<network name> -d -p 8001:80 <nginx/imagename>
Ping <ip address>172.19.0.2 = to check network working with container