> For the complete documentation index, see [llms.txt](https://docs.ionos.com/docker-machine-driver-1/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.ionos.com/docker-machine-driver-1/docker/docker-swarm.md).

# Docker Swarm

## Authentication

Before you create a Docker Machine with Ionos Cloud Docker Machine Driver, make sure you followed the [Authentication](/docker-machine-driver-1/usage/authentication.md) steps.

## Docker Machine Create Swarm Command

You can use Docker Machine to provision Swarm clusters.

Before you create a swarm of Ionos Cloud machines, run this command:

```
docker swarm init
```

Then use the output `${DOCKER_SWARM_TOKEN}` to create the swarm and set a swarm master:

```
docker-machine create --driver ionoscloud --swarm --swarm-master --swarm-discovery token://${DOCKER_SWARM_TOKEN} swarm-master-test
```

It should produce results similar to this:

```
Running pre-create checks...
Creating machine...
(swarm-master-test) Creating SSH key...
(swarm-master-test) DataCenter Created
(swarm-master-test) IPBlock Reserved
(swarm-master-test) LAN Created
(swarm-master-test) Server Created
(swarm-master-test) Volume Attached to Server
(swarm-master-test) NIC Attached to Server
(swarm-master-test) 158.222.102.158
Waiting for machine to be running, this may take a few minutes...
Detecting operating system of created instance...
Waiting for SSH to be available...
Detecting the provisioner...
Provisioning with ubuntu(systemd)...
Installing Docker...
Copying certs to the local machine directory...
Copying certs to the remote machine...
Setting Docker configuration on the remote daemon...
Configuring swarm...
Checking connection to Docker...
Docker is up and running!
To see how to connect your Docker Client to the Docker Engine running on this virtual machine, run: docker-machine env swarm-master-test
```

To create a swarm child, use the command:

```
docker-machine create -d ionoscloud --swarm --swarm-discovery token://${DOCKER_SWARM_TOKEN} swarm-child-test
```

When running `docker-machine ls`, it should produce results similar to this:

```
NAME                ACTIVE   DRIVER       STATE     URL                          SWARM                        DOCKER     ERRORS
swarm-child-test    -        ionoscloud   Running   tcp://158.222.102.154:2376   swarm-master-test            v20.10.5   
swarm-master-test   *        ionoscloud   Running   tcp://158.222.102.158:2376   swarm-master-test (master)   v20.10.5
```

For more details about possible issues, check the [Troubleshooting](/docker-machine-driver-1/docker/troubleshooting.md) guide.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.ionos.com/docker-machine-driver-1/docker/docker-swarm.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
