Skip to content

Basic Commands for VMware Photon and Docker

photon-logoThis 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

8 thoughts on “Basic Commands for VMware Photon and Docker”

  1. Pingback: Photon: linux by VMWARE | Ivan Zini

    1. It is just terrible!!!! I live in Belgium and you need to install the full installation to change the keyboard because you need the localectl command.

      Look at: https://communities.vmware.com/thread/511570?start=0&tstart=0

      But still then I did often the following commands to change the keyboard to get the right keys (figures,=_) But the key for : I did not find. To quit the vi editor, I use ZZ.

      For changing the network, I use "ip a" >> /etc/systemd/network/10.... and then change that file

      localectl set-keymap=be-latin1
      localectl set-keymap=uk

      So, buy a querty keyoard for working on consoles. It is everywhere the same ....

  2. This did not work on my installation. My network device is called "ens3", not "eth0". Even if I set Name=* it still does not take the static IP configuration.

Leave a Reply to franki Cancel reply

Your email address will not be published. Required fields are marked *