This post is a quick collection of commands used to configure VMwares recently released Photon OS, and to get started with Docker.

Photon is a technology preview of a minimal Linux container host. It is designed to have a small footprint and boot extremely quickly on VMware platforms. Photon is intended to invite collaboration around running containerized applications in a virtualized environment.

To get started with Photon, check this post.

Enable SSH access for root

#Change "PermitRootLogin no" to "PermitRootLogin yes" nano /etc/ssh/sshd_config systemctl restart sshd #Or sed -i 's/PermitRootLogin no/PermitRootLogin yes/g' /etc/ssh/sshd_config systemctl restart sshd

Configure Network

The network configuration is stored in /etc/systemd/network/10-dhcp-eth0.network. To configure a static IP address, disable DHCP configure static addresses:

root [ ~ ]# mv /etc/systemd/network/10-dhcp-eth0.network /etc/systemd/network/10-static-eth0.network root [ ~ ]# nano /etc/systemd/network/10-static-eth0.network root [ ~ ]# cat /etc/systemd/network/10-static-eth0.network [Match] Name=eth0 [Network] Address=192.168.79.134/24 Gateway=192.168.79.2 DNS=8.8.8.8 Domains=photon.local #Restart network root [ ~ ]# systemctl restart systemd-networkd.service #Display IP address information root [ ~ ]# ifconfig eth0 Link encap:Ethernet HWaddr 00:0C:29:BA:E5:39 inet addr:192.168.79.134 Bcast:192.168.79.255 Mask:255.255.255.0 UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1 RX packets:114 errors:0 dropped:0 overruns:0 frame:0 TX packets:98 errors:0 dropped:0 overruns:0 carrier:0 collisions:0 txqueuelen:1000 RX bytes:12757 TX bytes:16234 #Display routing table root [ ~ ]# ip route default via 192.168.79.2 dev eth0 proto static 192.168.79.0/24 dev eth0 proto kernel scope link src 192.168.79.134

Manage Services

#Start service systemctl start sshd #Stop service systemctl stop sshd #Restart service systemctl restart sshd #Configure a service to be automatically started at boot time systemctl enable sshd

Logfiles

Logfiles in Photon are managed by the journald daemon. To see the logs that the journald daemon has collected, use the journalctl command.



#Display all Logs journalctl #Display Logs from a specific Unit journalctl -u sshd #Display Kernel messages (Similar to dmesg) journalctl -k #Display only error messages (and higher) journalctl -p err # Active Monitoring (Follow Logs, similar to tail -f) journalctl -f # Display only last 20 lines (Similar to tail -20) journalctl -n 20

Docker Basics

#Start docker and enable it to be started at boot time systemctl start docker systemctl enable docker #Download a Docker container (https://registry.hub.docker.com/) docker pull vmwarecna/nginx #Display local stored Docker images docker images #Start Docker Container # -d - Run the container in the background # -p 80:80 - Publish the container's port to the host docker run -d -p 80:80 vmwarecna/nginx #List running Docker Containers docker ps #Display the public-facing port that is NAT-ed to the container #(Container ID from docker ps command) docker port 5f6b0e03c6de #Stop Docker Container docker stop 5f6b0e03c6de #Automatically start Docker containers at boot time #To start a container at boot time the restart policy parameter is used. docker run --restart=always -d -p 80:80 vmwarecna/nginx