Created
September 10, 2019 14:36
-
-
Save marcosleal-prd/b06eb2edb5e096389ab15de02bd7f02c to your computer and use it in GitHub Desktop.
Docker - Initial commands
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Show all running containers in the moment | |
docker ps | |
# Exibe todos os containers, it may be running or not. | |
docker ps -a | |
# Connects the terminal with that of the container. | |
docker run -it NOME_DA_IMAGEM | |
# Start container based on ID | |
docker start ID_CONTAINER | |
# Stop container based on ID | |
docker stop ID_CONTAINER | |
# Start container based on ID and integrates the terminals | |
docker start -a -i ID_CONTAINER | |
# Remove container based on ID | |
docker rm ID_CONTAINER | |
# Remove all stopped containers | |
docker container prune | |
# Remove image based on name | |
docker rmi NOME_DA_IMAGEM | |
# When executing, gives a name to the container | |
docker run -d -P --name NOME dockersamples/static-site | |
# Defines a specific port to be assigned to container port 80, in this case 12345 | |
docker run -d -p 12345:80 dockersamples/static-site | |
# Defines an AUTHOR environment variable with the value So and so in the created container | |
docker run -d -e AUTHOR="Fulano" dockersamples/static-site |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cria um volume no respectivo caminho do container. | |
docker run -v "CAMINHO_VOLUME" NOME_DA_IMAGEM | |
# Retorna diversas informações sobre o container. | |
docker inspect ID_CONTAINER |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cria uma imagem a partir de um Dockerfile. | |
docker build -f Dockerfile | |
# Constrói e nomeia uma imagem não-oficial informando o caminho para o Dockerfile. | |
docker build -f CAMINHO_DOCKERFILE/Dockerfile -t NOME_USUARIO/NOME_IMAGEM | |
# Inicia o processo de login no Docker Hub. | |
docker login | |
# Envia a imagem criada para o Docker Hub. | |
docker push NOME_USUARIO/NOME_IMAGEM | |
# Baixa a imagem desejada do Docker Hub. | |
docker pull NOME_USUARIO/NOME_IMAGEM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mostra o ip atribuído ao container pelo docker (funciona apenas dentro do container). | |
hostname -i | |
# Cria uma rede especificando o driver desejado. | |
docker network create --driver bridge NOME_DA_REDE | |
# Cria um container especificando seu nome e qual rede deverá ser usada. | |
docker run -it --name NOME_CONTAINER --network NOME_DA_REDE NOME_IMAGEM |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Cria imagens a partir do docker-compose.yml | |
docker-compose build | |
# Sobe os serviços criados | |
docker-compose up | |
# Para os serviços criados. | |
docker-compose down | |
# Lista os serviços que estão rodando. | |
docker-compose ps | |
# Executa o comando ping node2 dentro do container mvl-movies-1 | |
docker exec -it mvl-movies-1 ping node2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment