I initialize my container with 2 extra options that are not in the official instructions. Adding --name as portainer and configuring the --restart policy as unless-stopped.

docker run --name portainer --restart=unless-stopped -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

Updating to a new version is just 3 lines and 1 line to recreate the container.

sudo docker pull portainer/portainer-ce
sudo docker stop portainer
sudo docker rm portainer

docker run --name portainer --restart=unless-stopped -d -p 8000:8000 -p 9000:9000 -v /var/run/docker.sock:/var/run/docker.sock -v portainer_data:/data portainer/portainer-ce

Thanks to the `-v` parameter we used to bind a volume all data is stored on the host and all settings are preserved.

docker run reference
portainer installation