Cheat sheet Docker

## Available commands
docker help 
docker --help

## Specific Docker Command
man docker-run

## List Docker CLI commands
docker
docker container --help

## Display Docker version and info
docker --version
docker version
docker info

## Execute Docker image
docker run hello-world
docker run ubuntu /bin/echo 'Hello Jorge'

## List Docker images
docker image ls
docker images

## find an image to download
docker search debian

## Download image
docker pull debian:stable

## Create a container
docker run -i -t IMAGE_ID /bin/bash

exit to end session in your guest and the container will be stop and kept in your Docker

## see what container are known to your Docker
docker ps -a

## re-enter in one container
docker start CONTAINER_ID
docker attach CONTAINER_ID

## Save the container as a new image
docker commit CONTAINER_ID debian:stable

You can specify a new image name or overwrite the existing image name.


## List Docker containers (running, all, all in quiet mode)
docker container ls (or docker ps)
docker container ls --all (or docker ps -a)
docker container ls -aq  (or docker ps -aq)

## Create a Docker image
docker build -t IMAGE_NAME PATH_DIRECTORY

## Execute Docker image
docker run hello-world
docker run IMAGE_NAME
docker run -p 4000:80 IMAGE_NAME

## Run in background
docker run -d -p 4000:80 IMAGE_NAME
docker run --name CONTAINER_NAME -d ubuntu /bin/bash -c "while true; do echo 'Hello Docker'; sleep 1; done"

## Logs and see background container
docker logs -f CONTAINER_NAME

## End of the background process
docker container stop CONTAINER_ID
docker stop CONTAINER_NAME

## Start container an background process
docker start CONTAINER_NAME

## Delete all containers
docker rm -f $(docker ps -aq) 
docker rm $(docker ps -a -q)

## Delete all images
-f: forced
docker rmi $(docker images -q)

## login in the Docker public registry
docker login

## Associating a local image with a repository on a registry
docker tag IMAGE_NAME username/repository:tag

## Upload your image to the repository
docker push username/repository:tag

## Pull and run the image from the remote repository
docker run -p 4000:80 username/repository:tag

## use volumes: local file on container? 
docker run -v /home/user/Project:/mnt/Project -i -t IMAGE_ID /bin/bash

## multiple terminals to launch several session connected to the same container
docker exec -it CONTAINER_ID /bin/bash

Example:
docker run -it container_name bash (starts a new container with bash promt)
docker exec -it container_name bash (joins already running container's bash prompt)
Anuncios

Como recuperar datos de un .tar.bz2 corrupto

Creo que no hay mucho que decir. Solo que espero desarrollar en el futuro una mejor herramienta. Por ahora solo!.

Obtén bzip2recovery:

git clone https://github.com/jolth/bzip2recovery.git

Correr en el directorio dende este el fichero corrupto (por ejemplo):

./bzip2recovery.sh the_bad_backup.tar.bz2

Se debes mover bzip2recovery find_tar_headers.pl, a el directorio donde se encuentre el .tar.bz2 corrupto.

Cualquier sugerencia, bug, etc. Por favor háganmelo saber.

 

Autor: Jolth