Last active
September 20, 2024 02:36
-
-
Save alexishida/c4e7f31aced3e789cf8ba635837632e1 to your computer and use it in GitHub Desktop.
Comandos Docker
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
# Comandos basicos | |
docker pull mysql | |
docker images | |
docker run --name database -e MYSQL_ROOT_PASSWORD=teste123 -d mysql | |
docker ps | |
docker run --name blog --link database:mysql -e WORDPRESS_DB_PASSWORD=teste123 -p 80:80 -d wordpress | |
docker system prune | |
docker exec -i -t [nome] bash | |
docker rm [id] ou [nome] ou pelo os dois primeiros digitos do ID. | |
docker rm 3d 37 9f (exemplo) | |
docker stop [nome] | |
# Deleta todos os containers | |
docker rm $(docker ps -qa) | |
# Deleta todos os containers que estão parados | |
docker rm $(docker ps -q --filter=status=exited) | |
#Listar as imagens com a tag "none" (imagens incompletas) | |
docker images -f dangling=true -q (-q mostrar somente os ids) | |
docker rmi $(docker images -f dangling=true -q) | |
docker rmi [nome] | |
docker kill | |
docker logs | |
docker build -t docker-whale . | |
docker commit --change='CMD ["apachectl", "-DFOREGROUND"]' -c "EXPOSE 80" c3f279d17e0a svendowideit/testimage:version4 | |
docker commit c3f279d17e0a svendowideit/testimage:version3 | |
# Sincroniza hora do container | |
-v /etc/localtime:/etc/localtime:ro | |
# Limpa os logs | |
truncate -s 0 /var/lib/docker/containers/*/*-json.log | |
cat /dev/null > /var/lib/docker/containers/*/*-json.log | |
# Mostra qual processo está rodando | |
sudo lsof /var/lib/docker/containers/74bef250361c7817bee19349c93139621b272bc8f654ae112dd4eb9652af9515/shm | |
# Opcao para rotacionar os logs no json-file logging driver | |
--log-opt max-size=100m | |
--log-opt max-file=3 | |
# Atualizar a versao do docker no ubuntu (downgrade caso ocorra incompatibilidade) | |
sudo apt-get install docker-ce=17.03.2~ce-0~ubuntu-xenial | |
# Persistindo arquivos de configuracao para fora do container | |
sudo docker run --name tmp-nginx-container -d nginx | |
sudo docker cp tmp-nginx-container:/etc/nginx /host/path | |
sudo docker rm -f tmp-nginx-container | |
# Rodando docker como job | |
# Crie um script.sh para poder rodar na cron e copie o codigo abaixo: | |
#!/bin/bash | |
/usr/bin/docker run --rm \ | |
--name=container_name \ | |
--link banco:db \ | |
-v /etc/localtime:/etc/localtime:ro \ | |
-v /storage/app:/app \ | |
-w /app \ | |
imagem:latest /bin/bash start.sh | |
# Docker Compose | |
$ docker-compose up -d |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment