# Container demo: webserver with php This container demo shows how to run a simple php container. The goal is: - run a webserver - provide a simple webpage that shows the network configuration and env vars of the container ## Where to find the source OCI image The source image is on dockerhub under: [uwcloud/demo-php](https://hub.docker.com/r/uwcloud/demo-php) It's available for these platforms: - amd64 - armhf - arm64 ## Step #1: import the image This step: - imports the OCI image - defines the node service - versions increase automatically (if the version parameter is not passed in node_service_input) - LAN network: dhcp server with auto generated range - WAN network: allocated IP address - a demo environment variable - three hardware platforms - no file or directory mounts or persistent volumes - a memory limit of 50 MB ``` mutation import_demo_php { DM_import_node_service( input: { customer_id: "102e88a2-86cf-4a2d-8712-99e8e652db48" node_service_input: { container_image: "demo-php" name: "demo-php" apikey_roles: [] wipe_on_update: false environment_variables: [{key: "TESTVAR", value: "testvalue"}] access_gpsd_enabled: false network_config: { lan_configure_network: dhcp access_interfaces: { name: "eth1" label: "lan" } access_provided_subnet: "10.180.0.1/16" dhcp_range_template: "10.180.0.1/24" dhcp_lease_time_seconds: 600 wan_configure_network: allocated wan_dns_override: [] } } image_sources: [ { arch: amd64 image_reference: "uwcloud/demo-php:0.1" } { arch: armhf image_reference: "uwcloud/demo-php:0.1" } { arch: arm64 image_reference: "uwcloud/demo-php:0.1" } ] metadata: { memory_limit_mb: 50 } } ) } ``` This mutation returns an array of import job IDs. Their status can be checked until the import is complete. This typically just takes a few minutes. ```{hint} authentication options for private repositories can be passed for each image in the authn parameter ``` ### Checking job status This query allows you to check the job status with the job IDs received from the import mutation. ``` query job_status { DM_get_node_service_import_jobs(ids: ["ecb27001-1ede-451f-ae96-c529c7ef14f1", "e5c3da87-799c-468e-92d5-145715a9ed72", "580c9090-c678-42c4-b792-3c5fd7ce6213"]) { node_service_import_job_id state logs created last_modified arch } } ``` The output will show the state (in_progress, ok, failed) and a log of what happened after the import job is done. ## Step #2: Configuring it on a device Adding a container to a device can be done very quickly: - create a network uplink for the container (NAT or CloudLink) - for reliable aggregated uplinks across multiple modems or ethernets you could select CloudLink - attach the container to that uplink - optionally attach a LAN side to that container - since we passed the ```dhcp``` value to the ```lan_configure_network``` option above, an automatically configured dhcp server will be available on the LAN side - you can connect any device on that LAN port to access the container ## Step #3: Accessing the container You can connect your computer or a wireless access point bridged to that LAN port and then you will automatically get an IP address from the DHCP server. Then you can access the demo web page of the container using this URL: [http://10.180.0.1/](http://10.180.0.1/) And the output will be similar to this: ``` demo container with php This demo container shows the network configuration of the running container as a showcase of Unwired Edge Cloud. ip addr show: return_code=0 1: lo: mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000 link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/8 scope host lo valid_lft forever preferred_lft forever inet6 ::1/128 scope host valid_lft forever preferred_lft forever 2: eth0@if15: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:16:3e:dc:08:50 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 192.168.35.17/24 brd 0.0.0.255 scope global eth0 valid_lft forever preferred_lft forever inet6 fe80::216:3eff:fedc:850/64 scope link valid_lft forever preferred_lft forever 3: eth1@if16: mtu 1500 qdisc noqueue state UP group default qlen 1000 link/ether 00:16:3e:1e:00:a9 brd ff:ff:ff:ff:ff:ff link-netnsid 0 inet 10.180.0.1/16 brd 0.0.255.255 scope global eth1 valid_lft forever preferred_lft forever inet6 fe80::216:3eff:fe1e:a9/64 scope link valid_lft forever preferred_lft forever ip route show: return_code=0 default via 192.168.35.1 dev eth0 10.180.0.0/16 dev eth1 proto kernel scope link src 10.180.0.1 192.168.35.0/24 dev eth0 proto kernel scope link src 192.168.35.17 ... ```