Henry Poon's Blog

Setting up your own Counter-Strike 1.6 dedicated server via Docker

Once upon a time, you had to run the HLDSUpdateTool, and then SteamCMD. But now, awesome people on the internet have created Docker images for setting up a Counter-Strike 1.6 dedicated server. Now, all you have to do is:

  1. Install Docker on your machine
  2. Get a Docker image for a CS 1.6 server (I created this one, which is based off of an existing one. Mine has:
    • A lot of maps
    • Metamod
    • AMXModX (with high ping kicker, podbot control menu, round money, rock the vote, and admin all in one)
    • Podbot
  3. Customise the server (e.g. editing the server.cfg, amxx.cfg, and other config files, etc.)
  4. Start it up! (the README.md in the above linked Git repos has more info on this)

As far as ports go, I only needed to forward 27015 on my machine, but your mileage may vary. Others have reported that some more ports must also be forwarded on some machines.

Then optionally, if you’re running Ubuntu and you want this server to start up like a service via systemd, you’ll need this:

  1. An executable script with path /usr/local/bin/hlds with contents (make sure the DIR variable matches your installation directory):
#!/bin/sh

# Do not change this path
PATH=/bin:/usr/bin:/sbin:/usr/sbin:/usr/local/bin

# The path to the game you want to host. example = /home/newuser/dod
DIR=/opt/cs-16-server/bin
DAEMON=./server

start()
{
    echo  -n "Starting HLDS"
    if [ -e $DIR ]; then
        cd $DIR
        $DAEMON start
    else
        echo "No such directory: $DIR!"
    fi
}

stop()
{
    echo -n "Stopping HLDS"
    if [ -e $DIR ]; then
        cd $DIR
        $DAEMON stop
    else
        echo "No such directory: $DIR!"
    fi
}

reload()
{
    echo -n "Restarting HLDS"
    stop
    sleep 1
    start
}

case "$1" in
    start|stop|reload)
        "$1"
        ;;
    *)
        echo  "Usage: $ 0 {start | stop | reload | status}"
        exit  1
        ;;
esac

exit  0
  1. A script with path /etc/systemd/system/hlds.service with contents:
[Unit]
Description=HLDS

[Service]
Type=oneshot
ExecStart=/usr/local/bin/hlds start
ExecStop=/usr/local/bin/hlds stop
ExecReload=/usr/local/bin/hlds reload
RemainAfterExit=yes

[Install]
WantedBy=multi-user.target
  1. Then execute:
systemctl daemon-reload
systemctl enable hlds
service hlds start

Feel free to check out my server that’s running right now with the same Docker image! Here’s the command to connect via the console.

connect henrypoon.com:27015

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Next Post

Previous Post

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2024 Henry Poon's Blog

Theme by Anders Norén