DOCKER

Genival Rodrigues
2 min readJul 27, 2022

--

INSTALL

Executando docker com usuário atual sem utilizar SUDO:

#sudo usermod -aG docker ${USER}

#sudo chmod 666 /var/run/docker.sock

#docker ps

#docker run hello-word

#docker image ls

Instalando um servidor nginx

# docker run nginx:1.19.10-alpine

Executar container em segundo plano

# docker run -d nginx:1.19.10-alpine

Parar container rodando em segundo plano

#docker stop “ID_CONTAINER”

Determinando qual porta nosso container vai responder

# docker run -p 8000:80 nginx:1.19.10-alpine

Criei uma pasta docker e um arquivo html dentro dela, agora vou compartilhar meu arquivo com a imagem docker(esse conceito é chamado de volume):

# docker run -p 8000:80 -v $(pwd):/usr/share/nginx/html nginx:1.19.10-alpine

Habilitando o modo iterativo do container:

#docker exec -it “CONTAINER_ID” /bin/sh ( OU /bin/bash)

Instalando o vim de dentro da imagem:

#apk add vim

Rodando o mysql:

# docker run -v $(pwd)/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root mysql:5.7

# docker run -p 3306:3306 -v $(pwd)/mysql:/var/lib/mysql -e MYSQL_ROOT_PASSWORD=root mysql:5.7

Excluindo um container:

#docker rm “CONTAINER_ID”

Excluindo uma imagem:

#docker rmi “IMAGE_NAME”

Bibliografia

What is Docker?

Docker is a command-line program, a background daemon, and a set of remote services that take a logistical approach to solving common software problems and simplifying your experience installing, running, publishing, and removing software. It accomplishes this using a UNIX technology called containers.

Running software in containers for isolation

As noted earlier, containers have existed for decades. Docker uses Linux namespaces and cgroups, which have been part of Linux since 2007. Docker doesn’t provide the container technology, but it specifically makes it simpler to use.

Shipping containers

You can think of a Docker container as a physical shipping container. It’s a box where you store and run an application and all of its dependencies. Just as cranes, trucks, trains, and ships can easily work with shipping containers, so can Docker run, copy, and distribute containers with ease. Docker completes the traditional container metaphor by including a way to package and distribute

How to install Docker?

Get Docker

--

--

No responses yet