-
docker ps → See containers running
-
docker container ls → See containers running
-
docker ps -a → See all containers
-
docker container ls -a → See all containers
-
docker run docker/whalesay cowsay Docker → Run cowsay with message Docker
-
docker run node → Run node
-
docker run ubuntu → Run ubuntu
-
docker run nginx → Run nginx
-
docker run -it node → Run node and use node console
-
docker run -it ubuntu → Run ubuntu and use node console
- docker run -d nginx → Run nginx background
-
docker run -d -p 80:80 nginx → Run nginx background and in browser port 80
-
docker run -d -p 3000:80 nginx → Run nginx background and in browser port 3000
- docker run -d -p 80:80 --name nginx-container nginx → Run nginx with name nginx-container
- docker run -d -p 3306:3306 --name mysql_container --rm --network mysqlnetwork -e MYSQL_ALLOW_EMPTY_PASSWORD=True mysqlimage → Run mysql image with network
- docker run -d -v /var/lib/mysql -p 3306:3306 --name mysql_container --rm -e MYSQL_ROOT_PASSWORD=docker -e MYSQL_DATABASE=nodeDocker -e MYSQL_USER=felipe -e MYSQL_PASSWORD=dockerfelipe mysql:5.7
-
docker stop id → Stop docker container by container id
-
docker stop name → Stop docker container by container name
-
docker start id → Start docker container by container id
-
docker start name → Start docker container by container name
-
docker start -i name → Start docker and see logs
-
docker logs id → Logs docker container by container id
-
docker logs name → Logs docker container by container name
-
docker rm id → Remove docker container by container id
-
docker rm name → Remove docker container by container id
-
docker rm -f id → Force stop and remove docker container by container id
-
docker rm -f name → Force stop and remove docker container by container id
- docker cp node_container:/app/app.js ./copy/ → Copy the file app.js to a local folder copy
-
docker top container → See informations about container
-
docker inspect container → See id, createdData, image, etc
-
docker stats → See how many memory, cpu and some informations about every containers
-
FROM → Base image
-
WORKDIR → Application directory
-
EXPOSE → Application port
-
COPY → Files that need to be copied
FROM node
WORKDIR /app
COPY package*.json .
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]
-
docker build . → Build Dockerfile "docker build (root of Dockerfile)"
-
docker run -d -p 3000:3000 --name my_node id → Run Dockerfile
-
docker run -d -p 3000:3000 --name my_node name → Run Dockerfile
-
docker run -d -p 3000:3000 --name my_node --rm name → Run Dockerfile and when stop it is removed
-
docker image ls → See images
-
docker images → See images
- docker pull python → Dowload python
-
docker tag id name:tag → Change name and tag image
-
docker build -t name:tag . → Build with name and tag
-
docker rmi name → Remove image by name
-
docker rmi id → Remove image by id
-
docker systmem prune → Remove all containers, images and networks that are't being used
-
docker login → Login to docker
-
docker logout → Logout docker
-docker build -t 17102003/first_image_node . → Get image to docker hub
-
docker push 17102003/first_image_node → Push image to docker hub
-
docker pull 17102003/first_image_node → Update local image with hub image
-
docker build -t 17102003/first_image_node:1.0 . → Build image with a tag
-
docker push 17102003/first_image_node:1.0 → Push image with a tag
-
docker pull 17102003/first_image_node:1.0 → Pull image with a tag
-
docker run -d -p 3000:3000 --name test_image 17102003/first_image_node:1.0 → Run image
- docker volume ls → See all docker volumes
- docker run -d -p 80:80 --name node_container -v /data node_image → Run container and create a volume without name
- docker run -d -p 80:80 --name node_container -v name_volume:/var/www/html/messages node_image → Run container and create a volume with name
- docker run -d -p 80:80 --name php_container -v /mnt/c/Users/felip/workspace/2-study/udemy/docker/2-Volumes/messages:/var/www/html/messages --rm php_messages → Run container and create a volume and upload local folder
- docker run -d -p 80:80 --name php_container -v volumeleitura:/var/www/html:ro --rm php_messages → Create a read only volume
- docker volume create name → Create a volume
- docker volume inspect name → Inspect a volume
- docker volume rm name → Remove a volume
- docker volume prune → Remove unused volumes
-
bridge → Connect container to other container
-
host → Connect container to Host
-
macvlan → Connect container to container with MAC address
-
nonde → Container can't connect to other
-
plugins → Connect container with custom network (other person)
- docker network ls → See all networks
- docker network create my_network → Create a network
- docker network create -d macvlan my_network → Create a network with specific
- docker network rm my_network → Remove a network
- docker network prune → Remove unused networks
- docker network connect network container → Connect container a network
- docker network disconnect network container → Disconnect container a network
- docker network inspect networkname → Inspect a network
- docker-compose up → Run docker-compose
- docker-compose up -d → Run docker-compose without console
- docker-compose down → Stop docker-compose