Useful bash commands

This article is a living document and I’ll update it with new commands and change and fix any of the existing ones as needed.

Start CouchDB in a Docker container

Start CouchDB version 2.3.1 in a Docker container with port 5984 open so it’s available on the host on the same port.

sudo docker run -p 5984:5984 -d couchdb:2.3.1

Start CouchDB version 2.3.1 in a Docker container with all relevant ports open, a node name couchdb-0-project with a volume named volume-0-couchdb mounted to /opt/couchdb/data so CouchDB can use it for permanent storage.

sudo docker run -itd -p 5984:5984 -p 5986:5986 --name=couchdb0 -e NODENAME='couchdb-0-project' --mount 'source=volume-0-couchdb-project,target=/opt/couchdb/data' couchdb:2.3.1

Restart the container based on --name=couchdb0 on subsequent runs with

sudo docker restart couchdb0

Connect to a remote CouchDB that’s only listening on localhost

If your server is example.com, your username on that server is username, your ssh daemon is listening on a non-standard port 1000 (standard is 22), running this command will log you into that ssh server and create a tunnel from the server’s port 5984, where CouchDB normally listens, and your local port 22222.

This allows you to open http://localhost:22222 to reach your server’s CouchDB through the tunnel, with Fauxton available at http://localhost:22222/_utils.

ssh -p 1000 -L 22222:127.0.0.1:5984 username@example.com

In case your ssh server doesn’t use a non-standard port, and only uses port 22, the command becomes even simpler.

ssh -L 22222:127.0.0.1:5984 username@example.com

Any other useful command that you think should make this list?

This article is a living document and I’ll update it with new commands and change and fix any of the existing ones as needed.

Start typing to share your thoughts...