Tuesday, May 28, 2019

Docker command line

Docker compose up

docker-compose -f my_docker-compose.yml up

Removing All Unused Objects

docker system prune

Stop a particular container

docker container stop <<container_id>>

Removing Docker Containers

docker container ls -a
docker container rm id_container id_container

Remove all stopped containers

docker container ls -a --filter status=exited --filter status=created
docker container prune

Removing Docker Images

docker image ls
docker image rm id_image id_image

Remove dangling and unused images

docker image prune

Create your first docker container from repository (Docker hub)

docker search ubuntu (images name)
docker pull name_image
docker images
docker run -i -t image_id /bin/bash
exit
docker ps -a
docker start container_id
docker attach container_id (optional)
docker commit container_id your_name_image (optional)

Build an image with the Dockerfile

(I use “.” because you need to have Dockerfile in current directory).
docker build -t name_image .

Launching a container

docker run -ti my_image /bin/bash

Rename docker image

docker tag <old_name> <new_name>
docker rmi <old_name>

Push image on dockerhub or docker registry

docker tag id_image id_docker/your_name_image:your_version
docker push id_docker/your_name_image:your_version

Add your username to the docker group

sudo usermod -aG docker YOUR_USER

To apply the new group membership

su - YOUR_USER

Check if you user is added.

id -nG

Login to docker registry

docker login your_ip:your_port
usermame: your_username_docker_registry
password: your_pass_docker_registry

Running image detach mode

docker run -d --rm -p 9000:8080 your_image:version

Copy file in container.

docker cp path_local_file your_container_name:/path_file_your_replace

MariaDB


docker network create some-network 
docker run --detach --network some-network --name some-mariadb --env MARIADB_USER=<<YOUR_USER>> --env MARIADB_PASSWORD=<<YOUR_PASSWORD>> --env MARIADB_ROOT_PASSWORD=<<YOUR_PASSWORD>>  mariadb:latest
docker run -it --network some-network --rm mariadb mysql -hsome-mariadb -u <<YOUR_USER>> -p




No comments:

Post a Comment

Automating Deployments with CronJobs in Google Kubernetes Engine (GKE)

In the realm of container orchestration, automation plays a pivotal role in streamlining operations. Google Kubernetes Engine (GKE) offers r...