Skip to content

jalbertsr/docker-commands

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

16 Commits
 
 
 
 
 
 

Repository files navigation

docker-commands

🐳 Set of Docker commands

Commands

Install image from hub.docker
docker pull <imageName>
Run container
docker run -d <imagename> sleep <time>

where -d means run in background and <time> is the miliseconds the container will be alive

Execute a command iniside a container
docker exec <containerId> <command>
List all running containers
docker ps
List all images
docker images
Info about a container
docker inspect <containerId>
List all containers once runned
docker ps -a
Kill container
docker stop <containerName>
docker stop <containerId>
Remove containers
docker rm <containerId>
docker rm <containerName>
Remove image
docker rmi <imageName>
Open & enter to a docker image
docker run -it <
Mapping docker port(open port local)
docker run -p <hostPort:containerPort> <containerName>
Build image
docker build .

command will look for Dockerfile file

Name image
docker build . -t <username/imageName>
Login to hub.docker
docker login
Publish to hub.docker
docker push <imageName>

you have to be logged in


Kubernetes commands

Generate pod.yml file for kubernetes
kubectl run hello-world --image=fiunchinho/codely-docker:latest --restart=Never --port=80 --dry-run -o yaml > pod.yml

where --dry-run dosen't execute the command just "test" it.

Create a pod
kubectl create -f pod.yml

pod.yml can be a local file or a remote file via http://....

List all created pods
kubectl get pods
Describe/get info from a pod
kubectl describe pod hello-world
Delete pod
kubectl delete pod [pod name]
Automatic health check