1. Logs and monitoring
You can view logs of a container by
docker logs [container_name]
And you can monitor output from a container by
docker logs -f [container_name]
2. Open a shell in the container
If you want to quickly dive into the container, Continue reading
If you use docker for some time, there will be a lot of trash images, volumes that is not used by any containers. Here’s how to remove them. (warning: not reversible)
Remove dangling images
docker rmi $(docker images -qf dangling=true)
Remove dangling volumes
docker volume rm $(docker volume ls -qf dangling=true)
As seen from above commands, you may guess the nested command within the $(…) is used to list dangling images/volumes
List dangling images
docker images -f dangling=true
List dangling volumes
docker volume ls -f dangling=true
Ever want to use .env file config directly in Makefile? I found it not as easy as it sounds. I found this shell command on the web Continue reading
Docker containers are just like a computer, the networking between host and containers is affected by the firewall. My iptables has a default DROP all policy, but it will make the Containers cannot communicate with the host. Here is the fix you’ll need. Continue reading
Named volume is a new feature since Docker 1.9, it allows you to manage persistent data more easily, and also the volume can be provided by other storage drivers such as Glusterfs instead of “just a directory on the host”. This new feature is particularly useful in production environment. (On the Dev side, I think we still need mounted volume) Continue reading
It seems hard to find a complete step-by-step tutorial to install Jetty as a service (especially on CentOS), some of the tutorial online is somewhat outdated or does not work, so I will share what I’ve learnt. (painfully) Perhaps this tutorial will also be outdated at some point in the future, so I will state the current version of the software I use clearly. Continue reading
Envoy is a simple tool developed by the Laravel team. It is designed to perform task like deploying a website on a remote server, e.g. your VPS.
How does it work?
I want to share a little script I wrote that check if two directory is identical rather efficiently. First you may need to understand what sha1sum does.
The sha1sum tool
As the name may suggest, sha1sum compute the SHA-1 checksum of a particular file / text string.
[jason@madcoda ~]# echo "Hello World" | sha1sum
[jason@madcoda ~]# echo "Hello World" > hello.txt
[jason@madcoda ~]# sha1sum hello.txt
You can see from the above example that sha1sum produce a hash of the content, Continue reading
After moving one of my node from Linode to DigitalOcean, I have experienced strange crash that appears to be random. After I reboot the process it works for about a week and fails suddenly.
Tools for checking the data in the database
After some research, I think it could be caused by the data inside the database, since I moved all data from the old VPS to the new node and now I’m using a newer version of MySQL (Actually MariaDB). It could run into some compatibility problem.
I strongly recommand you to backup the database before running any checks, upgrade, repairs and optimize actions. You can do so with the command:
# cd ~
# mysqldump -A -p > mysql-all-databases.sql
This would check the status of all databases in the DB:
# mysqlcheck -aA -u root -p
This would repair the databases and tables if anything go wrong:
# mysqlcheck -rA -uroot -p
This would upgrade the data if you have upgraded the Mysql version:
# mysql_upgrade -uroot -p
Sometimes you want to run a command on your server through PHP. There are couple of ways to do it, system()、exec()、shell_exec(), passthru(). All of them pretty much works alright with some slight differences. I would like to share my method which I think is more “programmatic”. Continue reading