As more and more IoT/M2M devices are connected to the Internet, the IoT/M2M platforms normally deployed in the Cloud are increasingly overloaded with a large amount of data traffic. Though more resources in the cloud may be allocated to alleviate such overloading issues, this research proposes the alternative of utilizing Fog computing to extend the scalability of IoT/M2M platforms in the cloud. The Fog is used not only to offload the over congested cloud but also to provide low latency required by critical applications. Our first step is to migrate oneM2M, a global IoT/M2M platform, to a Fog computing architecture in which the middle nodes of oneM2M are organized into a highly scalable hierarchical container-based Fog nodes. We then design a mechanism to dynamically scale in/out the serving instances of the middle nodes in order to make the whole IoT/M2M platform more scalable. The paper illustrates our system design and demonstrates our system scalability capacity using an industrial IoT (IIoT) use case. Finally, we compare the performance of our dynamic scaling mechanism with those based on a static and fixed pool of serving instances.