Skip to main content

reset data-container


Resetting a data container allows you to remove all changes (schema and data) made to it since the last revision. This is useful when you want to discard the last changes you have made, especially ones that would be difficult to revert otherwise (e.g. dropping a table with data).


spawnctl reset data-container <ContainerNames_Or_ContainerIDs>


Reset a data-container with id 10001:

spawnctl reset data-container 10001

Reset a data-container with name dev:

spawnctl reset data-container dev

Reset multiple data-containers with ids 10001, 10002 and 10003:

spawnctl reset data-container 10001 10002 10003

Reset multiple data-container with names dev1, dev2:

spawnctl reset data-container dev1 dev2


In this tutorial we will create a data image, then create a data container from that image. We'll then make some changes to the data container (or database) followed by a reset operation. We will finally inspect the state of this data container.

As a prerequisite you should've followed the instructions to install spawnctl

  1. Create a file development.yaml with your data image specifications.

    sourceType: empty
    name: dev
    engine: postgresql
    version: 11.0

    In this case we want to create a PostgreSQL data image that is completely empty and is named dev.

  2. Run the following command to create a data image.

    $ spawnctl create data-image -f ./development.yaml
    Data image 'dev' (10001) created!
  3. You can verify your data image by running the following command.

    $ spawnctl get data-images
    dev 10001 PostgreSQL 2 Created 2 minutes ago
  4. Create a data container from the newly created data image.

    $ spawnctl create data-container --image dev
    Data container 'dev-rambbomj' (10001) created!
    ->;Port=53223;User ID=<some_user_id>;Password=<some_password>;
  5. You can verify your data container was properly created by running the following command.

    Notice the created data container has revision rev.0.

    $ spawnctl get data-containers
    dev-rambbomj 10001 rev.0 2 Running PostgreSQL 1 minute ago
  6. You should now be able to connect to your database and execute queries.

    In this example we connect to the PostgreSQL data container (database) using psql.

    $ psql -h -p 53223 -U <some_user_id>
    Password for user <some_user_id>:
    psql (10.5, server 11.0 (Debian 11.0-1.pgdg90+2))
    SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
    Type "help" for help.
    <some_user_id>=# CREATE TABLE customers(id INT);
    <some_user_id>=# \dt
    List of relations
    Schema | Name | Type | Owner
    public | customers | table | <some_user_id>
    (1 row)
  7. We can now perform a reset operation on this data container.

    $ spawnctl reset data-container dev-rambbomj
    Data container 'dev-rambbomj' reset!
  8. You can now connect to this data container (database) and verify its content.

    $ psql -h -p 53223 -U <some_user_id>
    psql (10.5, server 11.0 (Debian 11.0-1.pgdg90+2))
    SSL connection (protocol: TLSv1.2, cipher: ECDHE-RSA-AES256-GCM-SHA384, bits: 256, compression: off)
    Type "help" for help.
    <some_user_id>=# \dt
    Did not find any relations.

    Notice that there are no relations even though we just added the table customers. This is because all data changes that happened after our last save are removed and the data container is restarted for the data at that checkpoint.