Skip to main content
  1. Tech/

Docker in 5 minutes

·2 mins

I have been using Docker and Kubernetes for several years now but never really took any time to really read about it. There were a lot of gaps in my understanding of how Docker works and what really is possible with it. Just recently my employer started to offer a Udemy subscription, so I took the Hands on Docker course. Here are some of the important things I learned in this course.

Where do you run Docker containers
#

You run these in Windows or MacOS but most likely you will use Linux in production. And unlike Windows and MacOS, you can run Docker on Linux VPS.

Important Docker commands
#

# get running docker containers
docker ps

# get all docker containers including those that have exited
docker ps -a

# stop container by its id or name
docker stop first_few_chars_of_id

# list docker images stored on the host
docker images

# remove image
docker rmi image_name

# download a new image
docker pull image_name
docker pul image_name:specific_tag

# append a command
docker run image_name command to run with parameters
docker run ubuntu sleep  5

# execute command in a conatiner
docker exec container_id cat /etc/hosts

# interactive session inside container
docker exec -it conatiner_id /bin/bash

# run container in background/daemon mode
docker run -d webapp

# tail logs
docker logs -f conatiner_id

# attach to conatiner running in detach/daemon mode
docker attach container_id

# map ports, for example, to map port 80 on host to port 8080 in container
dokcer run -p 80:8080 webapp

Related

Json_error_ctrl_char

·1 min
I was using mcrypt to encrypt json_encoded data. On the other side, mcrypt was able to decrypt data but json_decode was not working. It would throw JSON\_ERROR\_CTRL_CHAR error. However, without mcrypt, json_decode worked flawlessly. After some trial and error, I found that applying trim function after decrypting data would let me use json_decode without any issues.

Error Xcode Select Error Tool Xcodebuild Requires Xcode Active Developer Directory Command Line Tools Instance

·1 min
Playing with Cordova, I was getting this error when building iOS version: Error: xcode-select: error: tool 'xcodebuild' requires Xcode, but active developer directory is a command line tools instance Even full install of Xcode didn’t fix this error. The solution was to run the following command to use full Xcode instead of command line tools version that I had installed earlier: sudo xcode-select --switch /Applications/Xcode-beta.app/Contents/Developer