node-offly
v1.0.10
Published
Cloud hosted docker containers right from Node.js, completely free, using the offly API.
Maintainers
Readme
The easiest way to use docker without installing it or paying for a cloud service.
Quickstart
Note: You'll need an offly API key in order to use the Node.js API. Don't worry, we only require an API key for verification. The service is completely free!
First, install node-offly:
npm install node-offlyThen, import it into your project:
const offly = require("node-offly");Then, the first thing you need to do is call offly.init() with your API key to get authenticated:
const offly = require("node-offly");
offly.init("YOUR_API_KEY");Note: It is a better idea to store API keys in environment variables instead of exposing them in your code. Don't ever share your API key with anyone, because your API key gives access to your containers.
Examples
Create a docker container:
offly.createContainer(IMAGE, NAME, PASSWORD);
// Example (creates an Ubuntu 24.04 container)
// The password field is a custom password for
// the user account inside the container
offly.createContainer("offly", "MyAwesomeContainer", "password123").then(() => {
console.log("Container created!");
});Note: For all available images, see the official documentation.
Start a docker container:
offly.startContainer("MyAwesomeContainer").then(() => {
console.log("Container started!");
});Note: All functions in the API will return a promise.
Stop a docker container:
offly.stopContainer("MyAwesomeContainer");Remove a container:
// Example
// The password field should be your offly account
// password, which is required for verification
// when deleting containers
offly.removeContainer("MyAwesomeContainer", "password123");Rename a container:
offly.renameContainer("MyAwesomeContainer", "SomeOtherName");Set the current container in the workspace (optional) for ease of use:
offly.workspace.currentContainer = "MyAwesomeContainer";
// Now you can just call functions without the name!
offly.stopContainer();
offly.startContainer();
offly.execCommand("ls -l /");All methods
Containers API
Main functions for creating containers, removing containers, etc.
createContainer(image, name, password)image: String. The image you want to create the container with.name: String. The custom name for this container. Must be between 3-30 characters and only contain letters, numbers, and underscores.password: String. The password for the user inside the container. Will be used for SSH and other logins. Must be between 8-60 characters.
removeContainer(name, password)name: String. The name of the container you want to remove.password: String. Your offly account password. Required for verification when deleting containers.
renameContainer(name, newName)name: String. The name of the container you want to rename.newName: String. The new name for this container. Must follow same naming rules as before.
startContainer(name)name: String. The name of the container you want to start.
stopContainer(name)name: String. The name of the container you want to stop.
execCommand(name, command, stream, callback)name: String. The name of the container you want to execute the shell command in.command: String. Any shell command you want to execute inside this container.stream: Boolean. Whether the command's output should be streamed as it runs or if all output will be returned when the command finishes.callback(output): Function. Ifstreamis set totrue, then all stderr and stdout data will be streamed here. The output will be an object containing.stderr,.stdout, and.finished.
logs(container)container: String. The name of the container you want to retrieve logs from.
Filesystem API
Functions for accessing and controlling files inside of containers.
readFile(container, path)container: String. The name of the container you want to read the file in.path: String. The path to the file inside the container you want to read.
writeFile(container, path, data)container: String. The name of the container you want to write the file in.path: String. The path to the file inside the container you want to write to.data: String. The UTF-8 contents you want to write to the file.
addFile(container, path)container: String. The name of the container you want to create the file in.path: String. The path to the new file you want to create inside the container.
addFolder(container, path)container: String. The name of the container you want to create the folder in.path: String. The path to the new folder you want to create inside the container.
copyFile(container, file, directory)container: String. The name of the container you want to copy the file or folder in.file: String. The path to the original file or folder you want to copy inside the container.directory: String. The path to the target directory you want to copy the file or folder to inside the container.
removeFile(container, path)container: String. The name of the container you want to delete the file or folder in.path: String. The path to the file or folder you want to delete inside the container.
moveFile(container, path, newPath)container: String. The name of the container you want to move the file or folder in.path: String. The path to the original file or folder you want to move/rename inside the container.newPath: String. The path where the file or folder will move to inside the container.
uploadFile(container, localPath, directory)container: String. The name of the container you want to upload the file to.localPath: String. The path to the local file on your computer that you want to upload.directory: String. The path to the directory inside the container where the uploaded file will be placed.
readDirectory(container, directory)container: String. The name of the container you want to read the directory in.directory: String. The path to the directory you want to read inside the container.
For more examples and better documentation, see the official offly Docs.
Support
Thanks for the contributions to all of our projects in 2025!
If you'd like to tell us about a problem you're having, have a curious question about offly or the offly API, or just want to provide a thanks, open an Issue on our GitHub repository or reach out to us using the contact page.
License
The offly Node.js/NPM package and all offly related services are licensed under the GPL 3.0 License.
Copyright © 2021-2025 Parking Master
Copyright © 2025 offly
